I am writing program for dynamic button. On pressing the dynamic button (1,2,3,next,previous) it should show me content from the table. It is showing me content of first page only. Beside this my next button is also not working. On pressing next button it is showing object not found. My code is following <?php $con = mysql_connect("localhost","root"); $s = $_POST['name']; echo $s; if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("mydata", $con); $result = mysql_query("SELECT * FROM mytable"); $rows_per_page = 5; $tot_rec = mysql_num_rows($result); echo $tot_rec; $pages=ceil($tot_rec/$rows_per_page); echo $page; if(!isset($screen)) { echo "not set"; $screen=0; } $start = $screen * rows_per_page; echo $start; echo $rows_per_page; $sql = "select * from mytable LIMIT $start,$rows_per_page"; $result=mysql_query($sql); $rows=mysql_num_rows($result); for($i=0;$i<$rows;$i++) { $nam=mysql_result($result,$i,0); echo "$nam = $nam <br>\n"; } if($screen>0) { $url="select_sql3.php?screen=" .screen - 1; echo "<a href=\"$url\">Previous</a>\n"; } //page nubering link now. for($i=0;$i<$pages;$i++) { $url="select_sql3.php?screen=" .$i; echo "<a href=\"$url\">$i</a> /"; } if($screen <$pages) { $url="select_sql3.php?screen=" .screen + 1; echo "<a href=\"$url\">Next</a>\n"; }?> <form action="<?php print $PHP_SELF?>" method="get"> </form> </body> Please help me to debug this program
you have a missing GET method,You need to get that in order to show results $some=$_GET['screen']; then use some to decide what results u want to show Regards Alex
Thanks now it has started to show me content on pages. But on pressing next button it is showing error message 'object not found'. And it is also not showing previous button.
if($screen>0) { $url="select_sql3.php?screen=" .screen - 1; echo "<a href=\"$url\">Previous</a>\n"; } replace by if($screen>0) { $url="select_sql3.php?screen=" .$screen - 1; echo "<a href=\"$url\">Previous</a>\n"; } if($screen <$pages) { $url="select_sql3.php?screen=" .screen + 1; echo "<a href=\"$url\">Next</a>\n"; }?> by if($screen <$pages) { $url="select_sql3.php?screen=" .$screen + 1; echo "<a href=\"$url\">Next</a>\n"; }?>