yakk0 Posted December 15, 2008 Share Posted December 15, 2008 I can't seem to get the if statement to work and its now displaying blank on the page. <?php include "config.php"; $query="SELECT story_title, story_num FROM data order by story_num desc limit 5"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $story_title=mysql_result($result,$i,"story_title"); $story_num=mysql_result($result,$i,"story_num"); $story_note=['note']; if ($story_note==1) { echo "<img src='images/notice.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==2) { echo "<img src='images/updated.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==3) { echo "<img src='images/event.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==4) { echo "<img src='images/important.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } else { echo "<img src='images/notice.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/137094-how-if-statement-will-work/ Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 $story_note=['note']; This is not correct syntax. Link to comment https://forums.phpfreaks.com/topic/137094-how-if-statement-will-work/#findComment-716052 Share on other sites More sharing options...
B34ST Posted December 15, 2008 Share Posted December 15, 2008 try this instead <?php include "config.php"; $query="SELECT story_title, story_num FROM data order by story_num desc limit 5"; $result=mysql_query($query); $i=0; while($row = mysql_fetch_array($result)) { $story_title = $row['story_title']; $story_num = $row['story_num']; $story_note = $row['note']; if ($story_note==1) { echo "<img src='images/notice.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==2) { echo "<img src='images/updated.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==3) { echo "<img src='images/event.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } elseif ($story_note==4) { echo "<img src='images/important.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } else { echo "<img src='images/notice.png'> <a href='show_story.php?story_num=$story_num'><font color='white' size='2'>$story_title</font></a><br><br>"; $i++; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/137094-how-if-statement-will-work/#findComment-716055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.