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
https://forums.phpfreaks.com/topic/90654-loop-that-seems-to-end/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.