Hello! I have been tinkering with a script which will allow me to list names by the first letter of their last name. I have two test pages, the first of which has links to each letter, and the second page was supposed to display the db records in which the last name begins with the selected letter. At the moment, when I click the letter, all records are displayed, not just the selected letter. What am I doing wrong?
Page 1:
<a href=alpha4.php?alpha=A>A</a>
<a href=alpha4.php?alpha=B>B</a>
<a href=alpha4.php?alpha=C>C</a>
<a href=alpha4.php?alpha=D>D</a>
etc...
Page 2:
$alpha = $alpha . '%';
$sqlquery = "SELECT * FROM contacts WHERE lname LIKE '$alpha' ORDER BY lname";
$queryresult = mssql_query($sqlquery) or die(" Could not execute mssql query !");
$row = mssql_fetch_row($queryresult);
$id = $row[0];
$lname = $row[1];
$tdcount = 1;
$numtd = 1; // number of cells per row
echo '
mssql_data_seek($queryresult,0) ;
while($row = mssql_fetch_array($queryresult)) {
if ($tdcount == 1) echo "<tr>";
echo '
<td>'.$row['d_id'],'</td>
<td><a href="view.php?d_id='.$row['id'].'">'.$row['lname'].', '.$row['fname'].'</a></font></td>' ;
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
?>