Note that there are some explanatory texts on larger screens.

plurals
  1. POfor each result that = 1 add cell to table row?
    text
    copied!<pre><code>&lt;? // Set the MySQL Configuration $db_host = "test"; $db_user = "test"; $db_password = "test"; $db_name = "test"; $db_table = "test"; // Start Connection $db_connect = mysql_connect ($db_host, $db_user, $db_password); // Select Database $db_select = mysql_select_db ($db_name, $db_connect); $query = "SELECT bird_owner, place_name, funds, place_description FROM bird_locations"; $query2 = "SELECT blue_bird, red_bird, green_bird, gold_bird, black_bird FROM bird_locations"; // this query ($query2) is to select just the birds so can check if any bird = 1 then add a new image cell in table // Execution MySQL Query $result = mysql_query($query); if($result) { // table headers echo '&lt;table width="90%" border="0" align="center" cellspacing="2" cellpadding="10"&gt; &lt;p&gt;&lt;p&gt;&lt;p&gt; &lt;tr&gt; &lt;th align="center"&gt;&lt;b&gt;Owner&lt;/b&gt;&lt;/th&gt; &lt;th align="center"&gt;&lt;b&gt;PlaceName&lt;/b&gt;&lt;/th&gt; &lt;th align="center"&gt;&lt;b&gt;Birds&lt;/b&gt;&lt;/th&gt; &lt;th align="center"&gt;&lt;b&gt;Funds&lt;/b&gt;&lt;/th&gt; &lt;th align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/th&gt; &lt;/tr&gt; '; //now i add a new row for each result which works. while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '&lt;tr&gt; &lt;td align="center"&gt;&lt;b&gt;' . $row['bird_owner'].'&lt;/b&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;b&gt;' . $row['place_name'].'&lt;/b&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;b&gt;&lt;img src="bird_blue_50px.png"/&gt;&lt;/b&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;b&gt;' . $row['funds'].'L$&lt;/b&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;b&gt;' . $row['place_description'].'&lt;/b&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;'; } echo '&lt;/table&gt;'; } //Close MySQL connection mysql_close($db_connect); ?&gt; </code></pre> <p>When the rows are generated the 3rd cell of a row is an image of a bird, but how can I make it so that if the value of a bird in the database is 1 that it shows an extra cell for another bird image?</p> <p>e.g. if</p> <ul> <li>blue_bird value equals 1 show image in row</li> <li>red_bird value equals 1 show a red bird image in row also</li> <li>green_bird value equals 1 show green bird image</li> <li>gold_bird value equals show gold bird image</li> <li>black_bird value equals show black bird image</li> </ul> <p>and if there value equals 0 then don't show that image in table</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload