I am new to php mysql so have had difficulty putting this question together. I have a JOIN query which works OK, and everything is fine except that the last echo does not work correctly.
The database value of
passState can be TRUE/FALSE so its value is always 1 or 0. The page is supposed to display the image
filename2.png if the value is 1, or the string
'xxx' if its value is 0.
What actually happens is either every row displays the image if
("{$row1['passState']}" == 1)and
'xxx' if set to 0.
There are various TRUE/FALSE values in the database, so I think the syntax of the last line is wrong, but I just can't find it.
Any suggestions?
Code:
<?php
$query1 = mysql_query("SELECT DISTINCT comment, url_small, title, pdf, passState
FROM topics
INNER JOIN quiz
ON topics.managerId = quiz.managerId
WHERE ( topics.$egroup = 1
AND quiz.userId = '$userId' )
ORDER BY topics.title
");
while ($row1 = mysql_fetch_array($query1))
{
echo "<img src = '../{$row1['url_small']}' /><br />\n";
echo "{$row1['title']} <br />\n";
echo "<a href='../{$row1['title']} .php'>blah, blah</a><br />\n";
echo "<a href='../{$row1['pdf']}' ><img src='filename1.jpg' /><br />\n";
echo "{$row1['comment']} <br />\n";
if ("{$row1['passState']}" == 1) {echo "<img src='filename2.png' /><br />\n";} else {echo " ";}
}
?>