How to NOT display empy db columns
Posted: Thu Mar 31, 2011 8:55 pm
Ok... here's the thing. my users fill out a form but don't have to fill out every box. IF they don't, however, the display page shows broken images.
Here is the display code:
And I'm not great with coding so if you could please show me how to do it using my code. Thanks~
Here is the display code:
Code: Select all
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM creatures ORDER BY RAND() LIMIT 100")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
// Print out the contents of the entry
echo "<a href=\"http://magistream.com/creature/".$row['code1'] ."\"><img src=\"http://magistream.com/img/" .$row['code1'] .".gif\"/></a> ";
echo "<a href=\"http://magistream.com/creature/".$row['code2'] ."\"><img src=\"http://magistream.com/img/" .$row['code2'] .".gif\"/></a> ";
echo "<a href=\"http://magistream.com/creature/".$row['code3'] ."\"><img src=\"http://magistream.com/img/" .$row['code3'] .".gif\"/></a> ";
echo "<a href=\"http://magistream.com/creature/".$row['code4'] ."\"><img src=\"http://magistream.com/img/" .$row['code4'] .".gif\"/></a> ";
}
?>