I have a MySql table.
I want to check its specific field in all the rows. If this field has a specific value in any of the rows, I want PHP to print something and if any of the row doesn’t have that value, then I want PHP to do something else.
look at this code:
$queryplus="SELECT * FROM comments WHERE id='$id' and comment='plus'";
$resultplus=mysql_query($queryplus) or die(mysql_error());
while($rowplus = mysql_fetch_array($resultplus))
{
$email3=$rowplus['email'];
$fname3=$rowplus['fname'];
$lname3=$rowplus['lname'];
$email=$_SESSION['email'];
}
if ($email==$email3)
{
echo "UNPLUS";
}
else
{
echo "PLUS";
}
In this code, if the last row inserted has $email=$email3 then the if command executes successfully and it prints UNPLUS, but if $email=$email3 is true in any other row than the last row, the command fails to execute and prints the PLUS.
Please tell me what’s wrong in it.
NOTE: $_SESSION[’email’] is the value of the email field of another table which has the value provided by the user who is logged in at the moment.
Try