Ciao a tutti,
ho un problema con un paging. Ecco il codice:
If (is_numeric($SubCategoryID)):
/* Numero totale dei records restituiti dalla query */
$Count = mysql_query("SELECT COUNT(id) FROM ricette
WHERE SubCategoryID = $SubCategoryID");
$res_count = mysql_fetch_row($Count);
echo "Records = " . $Records = $res_count[0] . "
";
/* Numero degli Items che vogliamo per pagina */
$ItemsPage = 7;
/* Numero totale delle pagine: floor arrotonda le frazioni all'intero inferiore;
Pagine totali che avremo = il numero di Items fratto il numero di Items per pagina */
$Pages = floor($Records/$ItemsPage);
echo "Pages = " .$Pages . "
";
/* Pagina corrente */
$Current_Page = (!$_GET["Page"]) ? 1 : (int)$_GET["Page"];
if (!isset($Page)) {
$Page = 1;
}
echo "Current Page = " . $Current_Page . "
";
/* Primo elemento da inserire nella pagina */
$First_Element = ($Current_Page) * $ItemsPage;
if ($Page == 1) {
$First_Element = 1;
}
/* Query per le SubCategory */
$SubCatQuery = "SELECT * FROM ricette
WHERE SubCategoryID = $SubCategoryID
ORDER BY titolo
LIMIT $First_Element, $ItemsPage";
echo $SubCatQuery . "
";
$SubCatBodyResult = mysql_query ($SubCatQuery,$db);
EndIf;
?>
Come risultato non ottengo gli ultimi 7 risultati: ad esempio ho una SubCategory che contiene 14 records ma ne vengono visualizzati solo 7 (così come con 35 records ne vengono visualizzati 28). Qualcuno può aiutarmi?
Grazie.
L.