techker Posted November 2, 2009 Share Posted November 2, 2009 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 More sharing options...
bruckerrlb Posted November 2, 2009 Share Posted November 2, 2009 You could try something like this if($row['status'] == 'empty') { //code to show image } else($row['status'] == 'not empty") { //code to show other image } Link to comment https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949373 Share on other sites More sharing options...
Bricktop Posted November 2, 2009 Share Posted November 2, 2009 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 More sharing options...
cags Posted November 2, 2009 Share Posted November 2, 2009 Sounds like you want... echo ($row['status']=="active") ? "image path/html for true" : "image path/html for not_active"; Link to comment https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949375 Share on other sites More sharing options...
techker Posted November 2, 2009 Author Share Posted November 2, 2009 Sounds like you want... echo ($row['status']=="active") ? "image path/html for true" : "image path/html for not_active"; ah...cool thx for the help!! Link to comment https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949377 Share on other sites More sharing options...
techker Posted November 2, 2009 Author Share Posted November 2, 2009 thx guys! Link to comment https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949378 Share on other sites More sharing options...
techker Posted November 2, 2009 Author Share Posted November 2, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.