Tidus
08-03-2002, 12:50 PM
Ok.
I have now made a lyrics page and it is supposed to find the first letter in every title i have in the database and list as displayed.
-A-
Abraham
Alan
Alva
Art
-B-
Bob
Bradley
-C-
Cary
Cletus
Now, with the code i have I can get it working, but it only does it once, it wont loop until there are no more records.. So have a song starting with D and one starting with H and i am only getting the H?
here is the code i am using:
$result = mysql_query("SELECT * FROM lyrics ",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
$firstChar = "";
while($myrow = mysql_fetch_array($result)) {
if ($firstChar != $myrow["title"][0]){
$firstChar = $myrow["title"][0]; // get the first char in the name
echo "<p />-" . $firstChar . "-<br />\n";
}
printf("<a href=http://www.handclaireonline.com/lyrics/lyrics.php3?id=%s>%s</a><br>\n",$myrow["id"],$myrow["title"]);
} while ($myrow = mysql_fetch_array($result));
} else {
I have now made a lyrics page and it is supposed to find the first letter in every title i have in the database and list as displayed.
-A-
Abraham
Alan
Alva
Art
-B-
Bob
Bradley
-C-
Cary
Cletus
Now, with the code i have I can get it working, but it only does it once, it wont loop until there are no more records.. So have a song starting with D and one starting with H and i am only getting the H?
here is the code i am using:
$result = mysql_query("SELECT * FROM lyrics ",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
$firstChar = "";
while($myrow = mysql_fetch_array($result)) {
if ($firstChar != $myrow["title"][0]){
$firstChar = $myrow["title"][0]; // get the first char in the name
echo "<p />-" . $firstChar . "-<br />\n";
}
printf("<a href=http://www.handclaireonline.com/lyrics/lyrics.php3?id=%s>%s</a><br>\n",$myrow["id"],$myrow["title"]);
} while ($myrow = mysql_fetch_array($result));
} else {