hi my paging wont work. whenever i click the next page, the record wont change and remain at page one.
php_paging.php
<html>
<head>
<title>Plus2net.com paging script in PHP</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
require "config.php";
$page_name="php_paging.php";
if(!isset($start))
{
$start =0;
}
$eu = ($start - 0);
$limit = 1; // No of records to be shown per page.
$this = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
//WE have to find out the number of records in our table
$result2 = mysql_query('SELECT * FROM custInfo');
echo mysql_error();
$nume=mysql_num_rows($result2);
// Now let us print the table headers
$bgcolor="#f1f1f1";
echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
// Now let us start executing the query with variables $eu and $limit
$query=" SELECT * FROM custInfo limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
//Now we will display the returned records in side the rows of the table
while($noticia = mysql_fetch_array($result))
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "<tr >";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[ID]</font></td>";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[Name]</font></td>";
echo "</tr>";
}
echo "</table>";
// End of displaying the table with records
// Start the buttom links with Prev and next link with page numbers
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
//if our variable $back is equal to 0 or more then only we will display the link to move back
if($back >=0) {
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
// Let us display the page links at center. We will not display the current page as a link
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";} // Current page is not displayed as link and given font color red
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
//If we are not in the last page then Next link will be displayed. Here we check that
if($this < $nume) {
echo "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
?>
<center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center>
</body>
</html>
config.php
<?php
$servername='localhost'; // Your MySql Server Name or IP address here
$dbusername=''; // Login user id here
$dbpassword=''; // Login password here
$dbname='sql_tutorial'; // Your database name here
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
//Database
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
//<br>
$selectDB = mysql_select_db('databasetest', $link);
}
?>