fife Posted October 28, 2010 Share Posted October 28, 2010 Hi I am trying to perform an echo yes if field from query is equal to one or no if anything else. See the code below, Now its erroring saying unexpected t variable in string and its also saying expecting ' It seems to be erroring at the start of my IF statement. So can anyone please help with what I have done wrong. This will be my first personal written IF statement so if it is miles off i apologise. <?php $qGetCat = ("SELECT * FROM category ORDER BY `id`"); $rGetCat = mysql_query($qGetCat) or die(mysql_error()); while($Cat = mysql_fetch_assoc($rGetCat)) { ?> <td height="31" align="left" nowrap="nowrap"><?= $Cat['id'] ?></td> <td align="left" nowrap="nowrap"><?= $Cat['cat1'] ?></td> <td align="left" nowrap="nowrap"> <?php if $Cat['top']='1' { echo "Yes";} else { echo "No";} ?> </td> <td><a href="updatetopcategory.php?=<?= $Cat['id'] ?>"><img src="../images/Edit.png" width="29" height="29" /></a></td> <td><img src="../images/delete.jpg" width="29" height="29" /></td> <? } ?> Link to comment https://forums.phpfreaks.com/topic/217086-if-statement-help/ Share on other sites More sharing options...
Anti-Moronic Posted October 28, 2010 Share Posted October 28, 2010 Hi fife, I believe it's this: if $Cat['top']='1' Argument should be enclosed in () : if ($Cat['top']='1' ) EDIT: By the way, I'd advise you stop early in using <?= short open tags. Use the full tag. it will only cause problems later for you. Link to comment https://forums.phpfreaks.com/topic/217086-if-statement-help/#findComment-1127455 Share on other sites More sharing options...
fife Posted October 28, 2010 Author Share Posted October 28, 2010 thank you for your help works great. Link to comment https://forums.phpfreaks.com/topic/217086-if-statement-help/#findComment-1127457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.