HughbertD Posted February 12, 2008 Share Posted February 12, 2008 Hi I am trying to page my results list This works the first time I click the "Next" link, but after that the link does nothing. <? echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>'; ?> <?php if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { //we give the value of the starting row to 0 because nothing was found in URL $startrow = 0; //otherwise we take the value from the URL } else { $startrow = (int)$_GET['startrow']; } $SQL = "select * from student order by lastName limit $startrow, 10"; echo ($SQL); $retid = mysql_query($SQL, $cid); if (!$retid) { echo( mysql_error()); } else { //check if the starting row variable was passed in the URL or not echo ("<table cellpadding=4 style=font-size:1em>"); ?> <tr> <td align="center">Name</td> <td align="center">Email</td> <td align="center">Phone Number</td> <td align="center">Mobile Phone</td> </tr> <?php while ($row = mysql_fetch_array($retid)) { $firstName = $row["firstName"]; $lastName = $row["lastName"]; $mobilePhone = $row["mobilePhoneNum"]; $phone = $row["phoneNum"]; $email = $row["email"]; $id = $row["studentID"]; echo ("<tr>"); echo ("<td>$firstName $lastName</TD>\n"); ?> <td align="center"> <?php echo ("$email")?></td><?php echo ("<td align=center>$phoneNum</td>\n"); echo ("<td align=center>$mobilePhone</td>\n"); echo ("<td><A HREF=\"../insertUpdateEdit/studentEdit.php?id=$id\">Edit</A></td>"); echo ("<td><A HREF=\"displayStudent.php?id=$id&task=del\">Delete</A></td>"); echo ("</tr>"); } echo ("</table>"); } ?> If anyone can help I would be really grateful, I've been scratching my head all morning Quote Link to comment Share on other sites More sharing options...
sasa Posted February 12, 2008 Share Posted February 12, 2008 move this part echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>'; after you set $startrow variable Quote Link to comment Share on other sites More sharing options...
HughbertD Posted February 12, 2008 Author Share Posted February 12, 2008 Thankyou! SOLVED! Quote Link to comment Share on other sites More sharing options...
GameYin Posted February 12, 2008 Share Posted February 12, 2008 Please click "Solved topic" Quote Link to comment 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.