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 />" ; } ?> Link to comment https://forums.phpfreaks.com/topic/175043-phpsql-help-needed/ 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 />" ; } ?> Link to comment https://forums.phpfreaks.com/topic/175043-phpsql-help-needed/#findComment-922542 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 Link to comment https://forums.phpfreaks.com/topic/175043-phpsql-help-needed/#findComment-923696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.