I am trying pagination on my website but the problem i am having that
my php code is only running fisrt time, if i click next or another
page i am getting Mysql query Error..
the problem is that on next page the variable is not taking the values
from the previous page. thats y it's giving me errors. or maybe there
are other problems also.
I am putting my code here..
<?php
//connect To database
include("connect2db.php");
$selected = $_POST['hidden'];
if($selected == "true") {
/*getting values from the main page my output page depends on these
values.*/
$surah = $_POST['surah'];
$start = $_POST["start"];
$end = $_POST["end"];
$check = $_POST["radio"];
$eng_tra = $_POST["chk_tra_eng"];
$urdu_tra = $_POST["chk_tra_urdu"];
echo "<br>Inside IF surah = <b>$surah</b><br>";
}
$limit = 20;
$totalrows = (1 + ($end - $start));
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$result = mysql_query("SELECT * FROM ayat WHERE s_no = 2 LIMIT
$limitvalue ,$limit");
$bgcolor = "#E0E0E0"; // light gray
echo("<table>");
while($row = mysql_fetch_array($result)){
if ($bgcolor == "#E0E0E0"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#E0E0E0";
}
echo("<tr bgcolor=".$bgcolor."><td>");
echo($row["e_ayat"]);
echo("</td><td>");
echo("<img src=\"".$row["a_ayat"]."\"></img>");
echo("</td></tr>");
}
echo("</table>");
if($page != 1){
$pageprev = $page--;
echo("<a href=\"demo.php&page=$pageprev\"> <<
PREV </a> ");
}else{
echo(" << PREV ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo(" ".$i." ");
}else{
echo("<a href=\"demo.php?page=$i\"> $i </a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"demo.php?page=$i\"> $i </a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"demo.php?page=$pagenext\"> NEXT
>> </a>");
}else{
echo(" NEXT >> ");
}
mysql_free_result($result);
?>
i will be thankful if anyone can help me with this, or suggest a
better way of doing this pagination.
Thank you
Shakeeb
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/