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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.