I am using php version 4.3.3.
The below was my pagination code.
My problem is that when i run this code in my computer, i wall fail because of the hyperlink of the pagination not function when i click it. But when i run in other people computer, It was no problem at all. I wonder to know what wrong to my coding . Is it different version of php also reflect the output?
[php]
<?
//required file for database connection
require("config .php");
$query = "SELECT ID,Name FROM listofitem ";
$result = mysql_query($qu ery);
$page_name="lis t.php";
$num_record = mysql_num_rows( $result);
$display =5;
$XX = 'Sorry, no results were found!';
// If there are no records then startrow
// is 0
if (empty($startro w)) {
$startrow=0;
}
$query2 = "SELECT ID,Name FROM listofitem LIMIT $startrow, $display";
$result2 = mysql_query($qu ery2);
echo "<table border='1'align =center>
<th bgcolor='#CCCFF F' align=left><fon t face='arial,ver dana,helvetica' size='2'><br>Na me</font></th>
$counter = 0;
while(list($ID, $Name) = mysql_fetch_arr ay($result2)) {
if ($counter == 3) {
$counter = 0;
}
echo"<td><font face='arial,ver dana,helvetica' size='2'><a href='Informati onPage.php?id={ $ID}'>{$Name}</a></font></td>";
echo"</tr>";
$counter = $counter + 1;
}
// End loop
// Calculate the previous results, only
// print 'Previous' if startrow is not equa
// l to zero
if ($startrow != 0) {
$prevrow = $startrow - $display;
echo"<a href='$page_nam e?startrow=$pre vrow'>prev</a> ";
}
// Calculate the total number of pages
$pages = intval($num_rec ord / $display);
if ($num_record % $display) {
$pages++;
}
// Print the next pages, first check if
// there are more pages then 1
if ($pages > 1) {
for ($i=1; $i <= $pages; $i++) { // Begin loop
$nextrow = $display * ($i - 1);
echo"<a href='$page_nam e?startrow=$nex trow'>[$i]</a> ";
}
}
//End loop
// Check if we are at the last page, if
// so, dont print 'Next'
if (!(($startrow / $display) == $pages) && $pages != 1) {
// not the last page so print 'Next'
$nextrow = $startrow + $display;
echo"<a href='$page_nam e?startrow=$nex trow'>next</a>";
}
// If there are no results at all
if ($num_record < 1) {
echo"<table border=0 width=795><tr>< td>$XX</td></tr></table>";
echo"</table>";
echo"<br><br><b r><a href='index.php ? '>[back]</a>";
}
?>
[/php]
The below was my pagination code.
My problem is that when i run this code in my computer, i wall fail because of the hyperlink of the pagination not function when i click it. But when i run in other people computer, It was no problem at all. I wonder to know what wrong to my coding . Is it different version of php also reflect the output?
[php]
<?
//required file for database connection
require("config .php");
$query = "SELECT ID,Name FROM listofitem ";
$result = mysql_query($qu ery);
$page_name="lis t.php";
$num_record = mysql_num_rows( $result);
$display =5;
$XX = 'Sorry, no results were found!';
// If there are no records then startrow
// is 0
if (empty($startro w)) {
$startrow=0;
}
$query2 = "SELECT ID,Name FROM listofitem LIMIT $startrow, $display";
$result2 = mysql_query($qu ery2);
echo "<table border='1'align =center>
<th bgcolor='#CCCFF F' align=left><fon t face='arial,ver dana,helvetica' size='2'><br>Na me</font></th>
$counter = 0;
while(list($ID, $Name) = mysql_fetch_arr ay($result2)) {
if ($counter == 3) {
$counter = 0;
}
echo"<td><font face='arial,ver dana,helvetica' size='2'><a href='Informati onPage.php?id={ $ID}'>{$Name}</a></font></td>";
echo"</tr>";
$counter = $counter + 1;
}
// End loop
// Calculate the previous results, only
// print 'Previous' if startrow is not equa
// l to zero
if ($startrow != 0) {
$prevrow = $startrow - $display;
echo"<a href='$page_nam e?startrow=$pre vrow'>prev</a> ";
}
// Calculate the total number of pages
$pages = intval($num_rec ord / $display);
if ($num_record % $display) {
$pages++;
}
// Print the next pages, first check if
// there are more pages then 1
if ($pages > 1) {
for ($i=1; $i <= $pages; $i++) { // Begin loop
$nextrow = $display * ($i - 1);
echo"<a href='$page_nam e?startrow=$nex trow'>[$i]</a> ";
}
}
//End loop
// Check if we are at the last page, if
// so, dont print 'Next'
if (!(($startrow / $display) == $pages) && $pages != 1) {
// not the last page so print 'Next'
$nextrow = $startrow + $display;
echo"<a href='$page_nam e?startrow=$nex trow'>next</a>";
}
// If there are no results at all
if ($num_record < 1) {
echo"<table border=0 width=795><tr>< td>$XX</td></tr></table>";
echo"</table>";
echo"<br><br><b r><a href='index.php ? '>[back]</a>";
}
?>
[/php]