01hanstu Posted September 21, 2009 Share Posted September 21, 2009 Hi, as it stands my code gets results from the news table and 'echo's' them on the page. I Have an image that prints with the message but what i want to know is, is it possible to to have the image print depending on the results of the 'severity column' so then the messages appear an appropriate image is shown so people know the severity? ATM My DB has 5 columns: ID, TITLE, MESSAGE, USER and SEV, but im unure how to bind the SEV column to images can anyone help. My code is at the bottom if it help Thanks Stuart <?php include ('inc/connect.php'); mysql_select_db($data_conn) or die( "Unable to select database"); $result = mysql_query("SELECT * FROM News"); while($row = mysql_fetch_array($result)) { echo "<img src=\"images/warning_32.png\" />"; echo "<B>"; echo $row['Title'] . " <br /></b>" . $row['Message'] . "</p><br />" ; } ?> Quote Link to comment Share on other sites More sharing options...
knsito Posted September 21, 2009 Share Posted September 21, 2009 <?php switch($row['Sev']){ case 'Sev1': echo "stuff"; break; case 'Sev2': echo 'stuff2'; break; default: //anything else } ?> or use if else etc I would read up on http://www.php.net/manual/en/language.control-structures.php Pretty basic stuff you will need to know Hi, as it stands my code gets results from the news table and 'echo's' them on the page. I Have an image that prints with the message but what i want to know is, is it possible to to have the image print depending on the results of the 'severity column' so then the messages appear an appropriate image is shown so people know the severity? ATM My DB has 5 columns: ID, TITLE, MESSAGE, USER and SEV, but im unure how to bind the SEV column to images can anyone help. My code is at the bottom if it help Thanks Stuart <?php include ('inc/connect.php'); mysql_select_db($data_conn) or die( "Unable to select database"); $result = mysql_query("SELECT * FROM News"); while($row = mysql_fetch_array($result)) { echo "<img src=\"images/warning_32.png\" />"; echo "<B>"; echo $row['Title'] . " <br /></b>" . $row['Message'] . "</p><br />" ; } ?> Quote Link to comment Share on other sites More sharing options...
01hanstu Posted September 23, 2009 Author Share Posted September 23, 2009 Brilliant Thats worked Thanks a lot knsito Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.