kproc
01-15-2007, 08:33 PM
The below code is supposed to get the next five names. For some reason its to doing anything when I click next. any help is excellent
<?
// groups and count the number of family names found in database
if(empty($_GET['start'])){
$start=0;
}else{
$start=$_GET['start'];
}
$end=$start+5;
$sql= mysql_query("SELECT last_name, count( * ) AS count FROM `users` GROUP BY `last_name` LIMIT $start,$end");
?>
<table class="columntable">
<tr><td class="tableheader" colspan="2">Registerd Family Names</td></tr>
<tr><td class="rowLeft">Last Name</td>
<td class="rowRight">Family Count</td></tr>
<?php
while($r=mysql_fetch_assoc($sql)) {
$query = mysql_query("SELECT last_name FROM `users` WHERE `last_name` = '$r[last_name]'") or die(mysql_error());
$last_name = $r['last_name'];
$count = mysql_num_rows($query);
?>
<tr>
<td class="rowLeft"><? echo $last_name; ?>
</td>
<td class="rowRight"><?php echo $count; ?>
</td>
</tr>
<?php }
$back = $_SERVER['PHP_SELF']."?start=$end";
?>
<tr style="background-color:#ECFEE9;"><td><input type="button" value="Next" onClick="window.location=<?php echo $back; ?>" /></td>
<td><input style="float:right;" type=button value="Prev" onClick="history.go(-1)"></td></tr>
</table>
<?php
<?
// groups and count the number of family names found in database
if(empty($_GET['start'])){
$start=0;
}else{
$start=$_GET['start'];
}
$end=$start+5;
$sql= mysql_query("SELECT last_name, count( * ) AS count FROM `users` GROUP BY `last_name` LIMIT $start,$end");
?>
<table class="columntable">
<tr><td class="tableheader" colspan="2">Registerd Family Names</td></tr>
<tr><td class="rowLeft">Last Name</td>
<td class="rowRight">Family Count</td></tr>
<?php
while($r=mysql_fetch_assoc($sql)) {
$query = mysql_query("SELECT last_name FROM `users` WHERE `last_name` = '$r[last_name]'") or die(mysql_error());
$last_name = $r['last_name'];
$count = mysql_num_rows($query);
?>
<tr>
<td class="rowLeft"><? echo $last_name; ?>
</td>
<td class="rowRight"><?php echo $count; ?>
</td>
</tr>
<?php }
$back = $_SERVER['PHP_SELF']."?start=$end";
?>
<tr style="background-color:#ECFEE9;"><td><input type="button" value="Next" onClick="window.location=<?php echo $back; ?>" /></td>
<td><input style="float:right;" type=button value="Prev" onClick="history.go(-1)"></td></tr>
</table>
<?php