How would I make it so when I select something from a mysql database, that information isn't stored in the array twice? Here is my code
<?php
include "header.html";
include "db.php";
if($_GET[by]==genre)
{
$sort = mysql_query("SELECT genre FROM bands ORDER BY genre");
while($sort2 = mysql_fetch_array($sort))
{
$sql=mysql_query("SELECT * FROM bands WHERE genre='$sort2[genre]' ORDER BY name");
$number=mysql_num_rows($sql);
$sort2[genre]=str_replace("%20", " ", "$sort2[genre]");
echo $sort2[genre]." (".$number.")<blockquote>";
while($rows=mysql_fetch_array($sql))
{
$name="$rows[name]";
$name2=str_replace("%20", " ", "$rows[name]");
echo "<a href=band.php?band=".$name.">".$name2."</a><br>";
}
echo "</blockquote>";
}
}
...
I have two entries with the genre 'metal.' and so when I execute this code, it displays the header 'metal' twice.