I have a list of items that don't show if they have not been selected. Now I don't want to show the topic if none of the items are selected. This is what shows::
My question is what is the best way to go about not displaying "Music I listen to:"?
Right now I can get the results I want when I use this in my code below
if ($band == null)
I am pretty sure I need to set it up so that it runs thru all of the different types of music but not sure what would be the best way to do that.
if ($band == null && barbershpr == null && classical == null && etc)
My code so far--
$sql = mysql_query("SELECT * FROM music WHERE userId = 'test'");
$results = mysql_fetch_array( $sql );
if ($band == null)
{
echo " Blank \n";
}
else
{
echo " <br><br>Music I listen to:
<span class='text'>
\n";
$sql = mysql_query("SELECT * FROM music WHERE userId = 'kelly'");
while($r = mysql_fetch_array($sql)) {
$string = "";
if ($r['band']) $string .= "Band, ";
if ($r['barbershop']) $string .= "Barbershop, ";
if ($r['classical']) $string .= "Classical, ";
if ($r['country']) $string .= "Country, ";
if ($r['dance']) $string .= "Dance, ";
if ($r['electric']) $string .= "Electroinical, ";
if ($r['folk']) $string .= "Folk, ";
if ($r['jazz']) $string .= "Jazz, ";
if ($r['metal']) $string .= "Metal, ";
if ($r['opera']) $string .= "Opera/Musicals, ";
if ($r['orchestra']) $string .= "Orchestra, ";
if ($r['punk']) $string .= "Punk Rock, ";
if ($r['ragtime']) $string .= "Ragtime, ";
if ($r['rap']) $string .= "Rap/Hip Hop, ";
if ($r['reggae']) $string .= "Reggae/Ska, ";
if ($r['religious']) $string .= "Religious, ";
if ($r['rock_pop']) $string .= "Rock/Pop/Alternative, ";
if ($r['world']) $string .= "World, ";
if ($r['othr_music']) $string .= $r['othr_music_txt'];
$string = rtrim($string, ", ");
echo " $string \n";
}
}
Right now I am having it echo "Blank" for testing purposes.