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 Quote 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 } Quote 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. Quote 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"; Quote 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!! Quote 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! Quote 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 />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179966-active-or-not/#findComment-949387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.