jbrill Posted August 22, 2007 Share Posted August 22, 2007 Hey guys, Im trying to get a div to to only display if the the row in the database called "stock" is equal to "1" if it is equal to "0 " then do not display the specific div. Here is the code: <?php $query = "SELECT * FROM products WHERE cat = '" . $curcat . "'" . $sSubCatAndClause . " AND publish = 1 AND featured = 0"; $rs = mysql_query($query); while($row2 = mysql_fetch_array($rs)) { echo "<div id=\"product\">"; //below is the div/image i want to appear only if out of stock is equal to 1 echo "<div style=\"outofstock\"><img src=\"images/featured.png\"></div>"; echo "<div id=\"producttext\">"; echo 'text will go here'; echo "</div>"; echo "</div>"; } ?> Thanks in Advance! Quote Link to comment https://forums.phpfreaks.com/topic/66248-solved-display-a-div-only-if-a-value-in-database-is-equal-to-1/ Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 if ($row2['stock'] == 1) echo "<div style=\"outofstock\"><img src=\"images/featured.png\"></div>"; Is that what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/66248-solved-display-a-div-only-if-a-value-in-database-is-equal-to-1/#findComment-331346 Share on other sites More sharing options...
jbrill Posted August 22, 2007 Author Share Posted August 22, 2007 thank you for the quick response! it worked great! Quote Link to comment https://forums.phpfreaks.com/topic/66248-solved-display-a-div-only-if-a-value-in-database-is-equal-to-1/#findComment-331378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.