SCUSATE L'INTRUSIONE
Avendo il tuo stesso problema ho provato il codice che hai postato ma non funziona a me sai dirmi dive sbaglio????
ecco il mio codice:
Codice PHP:
<?php
include("../Marinaservice/condb.php");
function getPagerData($numHits, $limit, $page) {
$numHits = (int) $numHits; //
$limit = max((int) $limit, 1); //convalidano la funzione di input: evitano divisioni per 0
$page = (int) $page; //
$numPages = ceil ($numHits / $limit); //calcola il numero delle pagine
$page = max($page, 1); //se il numero delle pagina è minore a 1, lo imposta come "1"
$page = min($page, $numPages); //se il numero della pagina è maggiore del numero totale delle pagine, lo imposta sull'ultimo numero disponibile delle pagine
$offset = ($page - 1) * $limit; //calcola l'offset
$ret = new stdClass; //
//
$ret->offset = $offset; //
$ret->limit = $limit; //sviluppa un piccolo oggetto di ritorno
$ret->numPages = $numPages; //
$ret->page = $page; //
//
return $ret;
}
// get the pager input values
$page = $_GET['page'];
$limit =2;
$query= "SELECT * FROM barche";
$select=mysql_query($query) or die("Query fallita");
$NumRow = mysql_num_rows($select);
if ($NumRow == 0) $NumRow = 1;
echo "
[url='ModificaCat.php?cod=Admin&idUtente=".$id."'] MODIFICA CATEGORIE [/url]
<table border='1' cellspacing='3'>
<caption align='top'>
Elenco Barche
</caption>
<tr>
<th scope='col'>Stato</th>
<th scope='col'>Modello</th>
<th scope='col'>Foto1</th>
<th scope='col'>Zoom1</th>
<th scope='col'>Foto2</th>
<th scope='col'>Zoom2</th>
<th scope='col'>Foto3</th>
<th scope='col'>Zoom3</th>
<th scope='col'>Prezzo</th>
<th scope='col'>Descrizione</th>
<th scope='col'>Categoria</th>
<th scope='col'></th>
<th scope='col'></th>
</tr>
";
while($row = mysql_fetch_array($select))
{
echo "
<tr>
<td>".$row['stato']."</td>
<td>".$row['modello']."</td>
<td>[img]".$row[[/img]</td>
<td>[img]".$row[[/img]</td>
<td>[img]".$row[[/img]</td>
<td>[img]".$row[[/img]</td>
<td>[img]".$row[[/img]</td>
<td>[img]".$row[[/img]</td>
<td>".$row['prezzo']."</td>
<td>".$row['descrizione']."</td>
<td>".$row['categoria']."</td>
<td>[url='ModificaBarca.php?cod=Admin&idUtente=".$id."&idBarche=".$row[']MODIFICA[/url]</td>
<td>[url='sql.php?cod=Admin&fare=cancella_barca&idBarca=".$row[']CANCELLA[/url]</td>
</tr>
";
}
echo"</table>";
// work out the pager values
$pager = getPagerData($NumRow, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// output del sistema di impaginazione
if ($page == 1 or $offset < 0){ // this is the first page - there is no previous page
echo "<< | ";
}
else{ // not the first page, link to the previous page
echo "<a href=\"$_SERVER[PHP_SELF]?page=" . ($page - 1) . "&id_topic=$ID_TOPIC\" class='notstandard'><<</a> | ";
}
for ($i = 1; $i <= $pager->numPages; $i++) {
if ($i == $pager->page){ // pagina attuale
echo "$i";
}
else{
echo "<a href=\"$_SERVER[PHP_SELF]?page=$i&id_topic=$ID_TOPIC\" class='notstandard'>$i</a>";
}
echo " | ";
}
if ($page == $pager->numPages){ // this is the last page - there is no next page
echo ">>";
}
else{ // not the last page, link to the next page
echo "<a href=\"$_SERVER[PHP_SELF]?page=" . ($page + 1) . "&id_topic=$ID_TOPIC\" class='notstandard'>>></a>";
}
?>



Rispondi quotando