Jump to content

Loop that seems to end?


HughbertD

Recommended Posts

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

Link to comment
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.