Below is the pagination coding that i had.My problem is i only know to display the 'Name' field in my result.
'while(list($Nama) = mysql_fetch_array($result2)) {'
How can i do if i want to display all the result as what i had do in query instead of only display one field.
$query = "SELECT * FROM listofitem ";
<?
//required file for database connection
require("config.php");
$query = "SELECT * FROM listofitem ";
$result = mysql_query($query);
echo"<h2 align=center>Name </h2>";
$num_record = mysql_num_rows($result);
$display = 20;
$XX = 'Sorry, no results were found!';
// If there are no records then startrow
// is 0
if (empty($startrow)) {
$startrow=0;
}
$query2 = "SELECT * FROM listofitem LIMIT $startrow, $display";
$result2 = mysql_query($query2);
echo "<table border='1'align=center>
<th bgcolor='#CCCFFF' align=left>Name<br></th>";
$counter = 0;
while(list($Nama) = mysql_fetch_array($result2)) {
if ($counter == 3) {
$counter = 0;
}
echo"<tr><td>$Name</td></tr>";
$counter = $counter + 1;
}
if ($startrow != 0) {
$prevrow = $startrow - $display;
echo"<a href=\"$PHP_SELF?startrow=$prevrow\">Previous</a> ";
}
$pages = intval($num_record / $display);
if ($num_record % $display) {
$pages++;
}
if ($pages > 1) {
for ($i=1; $i <= $pages; $i++) { // Begin loop
$nextrow = $display * ($i - 1);
echo"<a href=\"$PHP_SELF?startrow=$nextrow\">$i</a> ";
}
}
if (!(($startrow / $display) == $pages) && $pages != 1) {
$nextrow = $startrow + $display;
echo"<a href=\"$PHP_SELF?startrow=$nextrow\">Next</a>";
}
if ($num_record < 1) {
echo"<table border=0 width=795><tr><td>$XX</td></tr></table>";
}
?>