If all values are the same

Hi,

Im trying to do an if statement based on if one field in every entry has the same value, in this case 0.

Wondering if its possible. As you can see im selecting taster_Active from the database, then I wont to check if in every entry has 0 and if so show nothing, but even if one has a 1 instead it moves onto the else bit


$q=mysql_query("select taster_Active from Offers") or die (mysql_error());
$rows=mysql_fetch_assoc($q);
?>
<div id="mainHome_Nav_Drop">
<? if ($rows["taster_Active"] == "0") { ?>
<p style="color:#FFFFFF">Nothing to see here</p>
<? } else { ?>

got this sorted now by the seems:


<div id="mainHome_Nav_Drop">
<?
$sql = "select taster_Active from Offers where taster_Active = '1'";
$result = mysql_query($sql) or error(mysql_error());
if(mysql_num_rows($result) < 1)
{ ?>
<p style="color:#FFFFFF">Love it</p>
<? } else {


<div id="mainHome_Nav_Drop"> 
<? 
$sql = "select COUNT(taster_Active) AS c from Offers where taster_Active = '1'";
$result = mysql_query($sql) or error(mysql_error());  
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($row['c']) < 1)   
{ ?>  
<p style="color:#FFFFFF">Love it</p> 
<? } else {

Effectively does the same, but instead of retrieving all rows (which you then don’t use), just get the number of rows from MySQL, which is a lot more efficient! :slight_smile: