Hello all. I am a definite newbie to PHP and I'm kinda stuck. I've seen some other posts about this issue, but I never see the final answer to the guy's question.
I'm trying to display a query of a music database by the first letter of the artist's name/band name. Something like this:
A
ABBA Worst Hits LP Catalogue#: 666 Price: $6.66
B
Beuford's Band Albums Title CD Catalogue#: 999 Price $9.99
C
etc, etc.
OK, you get it. Here's my code so far:
//connect to database
$db="dig513_auctions";
mysql_select_db($db, $con);
$query = mysql_query("SELECT * FROM itemtype, music WHERE itemtype.typeid=music.format ORDER BY music.artist DESC");
$result=array();
?>
<?php
while ($row = mysql_fetch_array($query))
{
$first_char = strtoupper(substr($row['artist'],0,1)
);
if(!array_key_exists($first_char,$result))
$result[$first_char] = array();
array_push($result[$first_char],$row['artist');
}
foreach ($result as $key=>$value)
{
echo "<b>$key</b><br>";
foreach ($value as $v)
{
echo ucfirst($v)."<br>";
}
}
?>
As you may have guessed, I've 'borrowed' much of this code from elsewhere. Now that I can display each character (if it exists), how do I display the results underneath each letter?
Similar to Gary Gnu's Good Gnews....any Ghelp is Good Ghelp at this point <am i showing my age here?>
Cheers,
Jonathan
Sao Paulo