techker Posted April 7, 2010 Share Posted April 7, 2010 hey guys im doing a dealership script for my body and i have a user section.now when we creat a user i set levels. like 1 is full dealer price 2 is retail price 3 is retail - so now im wondering how can i do it that it can check the level(thats ok with a querry) $sql = "SELECT Level FROM $tbl_name WHERE ID = $ID"; $result = mysql_query($sql); now i have my php echo echo $info['Retail_price'] can i do something like //echo (empty($row['d'])? "empty": "not empty"); //result not empty but for level? Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/ Share on other sites More sharing options...
AdRock Posted April 7, 2010 Share Posted April 7, 2010 like this? $message = (empty($row['Level'])) ? "Empty" : "Not empty"; echo $message Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038652 Share on other sites More sharing options...
techker Posted April 7, 2010 Author Share Posted April 7, 2010 but this example is for if the table is empty.now i have numbers Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038656 Share on other sites More sharing options...
premiso Posted April 8, 2010 Share Posted April 8, 2010 $level = (empty($row['Level'])) ? $row['level'] : 0; If you want to test if the level is = 0 or null then you would change the empty logic. But empty checks if $row['level'] is 0 or "" etc. So it is still valid. It does not check null variables though. If it can be null use is_null. Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038693 Share on other sites More sharing options...
techker Posted April 8, 2010 Author Share Posted April 8, 2010 but what if there is a 1 0r 2? Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038893 Share on other sites More sharing options...
conker87 Posted April 8, 2010 Share Posted April 8, 2010 if ($row['Level'] == 1) { /* do full price */ } else if ($row['Level'] == 2) { /* do retail */ } else if ($row['Level'] == 3) { /* etc */ } Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038895 Share on other sites More sharing options...
techker Posted April 8, 2010 Author Share Posted April 8, 2010 if ($row['Level'] == 1) { /* do full price */ } else if ($row['Level'] == 2) { /* do retail */ } else if ($row['Level'] == 3) { /* etc */ } thx for the help!i will try it out. Link to comment https://forums.phpfreaks.com/topic/197936-user-levels/#findComment-1038898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.