jaiffed Posted February 28, 2010 Share Posted February 28, 2010 I have this script but it's not working properly it shows result but when i press next then same page and same result return in properly it shows next result <?php include('connect.php'); mysql_select_db($Db, $link); $limit=20; // rows to return $numresults=mysql_query("select * from mem_master"); $numrows=mysql_num_rows($numresults); if (empty($offset)) { $offset=0; } $result=mysql_query("select mem_id, mem_name, add1, add2, tel, mobile, email,balance". " from mem_master". " LIMIT $offset, $limit"); echo '<table width="100%" border="2">'; echo '<tr>'; echo "<td>" . "Member Id" . "</td>"; echo "<td>" . "Member Name " . "</td>"; echo "<td>" . "Address 1" . "</td>"; echo "<td>" . "Address 2" . "</td>"; echo "<td>" . "telephone" . "</td>"; echo "<td>" . "Mobile" . "</td>"; echo "<td>" . "Email" . "</td>"; echo "<td>" . "Balance" . "</td>"; echo '</tr>'; while ($data=mysql_fetch_array($result)) { echo "<tr> <td class='helpBod'>".$data['mem_id']."</td> <td class='helpBod'>".$data['mem_name']."</td> <td class='helpBod'>".$data['add1']."</td> <td class='helpBod'>".$data['add2']."</td> <td class='helpBod'>".$data['tel']."</td> <td class='helpBod'>".$data['mobile']."</td> <td class='helpBod'>".$data['email']."</td> <td class='helpBod'>".$data['balance']."</td> </tr>"; } echo '</table>'; if ($offset==1) { // bypass PREV link if offset is 0 $prevoffset=$offset-20; print "<a href=\"$PHP_SELF?offset=$prevoffset\">PREV</a> \n"; } $pages=intval($numrows/$limit); if ($numrows%$limit) { $pages++; } for ($i=1;$i<=$pages;$i++) { // loop thru $newoffset=$limit*($i-1); print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> \n"; } if (!(($offset/$limit)==$pages) && $pages!=1) { $newoffset=$offset+$limit; print "<a href=\"$PHP_SELF?offset=$newoffset\">NEXT</a><p>\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/193716-page-next-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.