Jump to content

PHP+Sql help needed


01hanstu

Recommended Posts

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.