Jump to content

active or not


techker

Recommended Posts

hey guys i have a databse set and in it there is a filed called status.

 

in it active or not active

 

i would like to echo if not_active show image/... if active show other image..

 

can somebody hel me with this?

 

i only cold get this going..

 

echo (empty($row['status'])? "empty": "not empty"); //result not empty

Link to comment
https://forums.phpfreaks.com/topic/179966-active-or-not/
Share on other sites

Hi techker,

 

The following should do what you need:

 

$status = (empty($row['status']) ? "active": "not active";
echo $status;

 

Simply replace the "active" and "not active" text with HTML image markup to show an image, e.g.:

 

<img src=\"images/image.jpg\" alt=\"Some Image\" />

 

The above assumes $row['status'] is the correct format for your query and table, and that you are using 0 and 1 to define active or not active.

 

Hope this helps.

 

Link to comment
https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949374
Share on other sites

Sounds like you want...

 

echo ($row['status']=="active") ? "image path/html for true" : "image path/html for not_active";

 

ah...cool thanks for the help!!

 

all godd thx!

 

<?php echo ($row['status']=="active") ? "<img src=icons/actif.jpg />" : "<img src=icons/inactif.jpg />"; ?>

Link to comment
https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949387
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.