dimanche 1 février 2015

php records navigation


<?php
$host='localhost';
$user='root';
$password='root';
$database='database';

$startindex=@$_REQUEST['seek'];

$db=mysql_connect($host, $user, $password)
or die ("Impossibile connettersi al server $host");

mysql_select_db($database, $db)
or die ("Impossibile connettersi al database $database");



$query="SELECT * FROM ordini_master";
$dbResult=mysql_query($query, $db);
$AffectedRows=mysql_affected_rows($db);

mysql_data_seek($dbResult, $startindex);

$row=mysql_fetch_row($dbResult);

foreach($row as $k=>$v)
{
$myfield=mysql_fetch_field($dbResult, $k);
print($myfield->name . " : $v <br/>");
}

mysql_free_result($dbResult);
mysql_close($db);

print("<br/>Seleziona il record<br/>");

for($index=0; $index<$AffectedRows; $index++)
{
print("<a href=\"{$_SERVER['PHP_SELF']}?seek=$index\" >" .
($index+1) . "</a> ");
}
?>


This code allow the navigation between a query records, so it create a page foreach record in database and so shows one record time. How can i modify that code to paging every 10 records? So i want to show 10 records time and create a page for the next.


Sorry for my english (I'm italian) , i hope you can help me.





Aucun commentaire:

Enregistrer un commentaire