In this 2 pages ( one if form & another is php processing file)
the result display only the 1st link and the remaining never show up.
here is the code.
1st page entry form. just copied PHP only.
---------------------------------
<form name="by_source" method="post" action="demo_pagingm.php">
<select id="docSource" name="docSource" style="azimuth:behind" >
<?php
$sql = "SELECT sourceID, sourceName " .
"FROM docsource ORDER BY sourceName";
$result = mysql_query($sql)
or die("<font color=\"#FF0000\">Query Error</font>" .
mysql_error());
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['sourceID'] . '"' .
$selected.'>' . $row['sourceName'] . '</option>' .
"\r\n";
//sourceName
}
?>
</select>
<input type="hidden" name="by_source" value="1"/>
<input type="submit" name="search_source" value="Search" />
</form>
----------------------
2nd file
demo_pagingm.php
---------------------------
<?php
?>
</head>
<body>
<?php
require "config.php"; // All database details will be included here
$page_name="demo_pagingm.php"; // If you use this code with a different page ( or file ) name then change this
$id=$_POST['docSource'];
$start = 0;
$start = $_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
echo "Select Number of records per page: <form method=get action=$page_name>
<select name=limit>
<option value=10 $select10>10 Records</option>
<option value=5 $select5>5 Records</option>
<option value=2 $select2>2 Records</option>
</select>
<input type=submit value=GO>";
// You can keep the below line inside the above form, if you want when user selection of number of
// records per page changes, it should not return to first page.
// <input type=hidden name=start value=$start>
////////////////////////////////////////////////////////////////////////
//
///// End of drop down to select number of records per page ///////
$eu = ($start - 0);
if(!$limit > 0 ){ // if limit value is not available then let us use a default value
$limit = 10; // No of records to be shown per page by default.
}
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query2="SELECT tbldocument.docID, tbldocument.docFileName,tbldocument.docTitle
FROM docsource INNER JOIN documentsource ON docsource.sourceID = documentsource.sourceID INNER JOIN
tbldocument ON documentsource.docID = tbldocument.docID
WHERE(docsource.sourceID = '$id') ORDER BY docEnterDate desc";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////
/////////// 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'>ID</font></td>";
echo "<td bgcolor='dfdfdf' > <font face='arial,verdana,helvetica' color='#000000' size='4'>File Name</font></td>";
echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#000000' size='4'>Date</font></td></tr>";
////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
$query="SELECT tbldocument.docID, tbldocument.docFileName, tbldocument.docTitle
FROM docsource INNER JOIN documentsource ON docsource.sourceID = documentsource.sourceID INNER JOIN
tbldocument ON documentsource.docID = tbldocument.docID
WHERE(docsource.sourceID = '$id') ORDER BY docEnterDate desc limit $eu, $limit ";
echo $query;
$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[docID]</font></td>";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[docFileName]</font></td>";
echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$noticia[docEnterDate]</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&limit=$limit'><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&limit=$limit'><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($this1 < $nume) {
print "<a href='$page_name?start=$next&limit=$limit'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
?>
</body>
</html>