Jump to content

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

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.