Jump to content

Recommended Posts

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";

}

 

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/193716-page-next-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.