Username: Posted December 16, 2010 Share Posted December 16, 2010 I'm writing an admin panel for my site (to manage users, etc) I selected the user-rights from the DB, but how can I check it the user-rights is equal to 3, and if it is allow access? Quote Link to comment https://forums.phpfreaks.com/topic/221914-sql-if-result-s/ Share on other sites More sharing options...
Maq Posted December 16, 2010 Share Posted December 16, 2010 WHERE user_rights = 3 If no results are returned, then they don't have those rights. Quote Link to comment https://forums.phpfreaks.com/topic/221914-sql-if-result-s/#findComment-1148359 Share on other sites More sharing options...
Rifts Posted December 16, 2010 Share Posted December 16, 2010 $sql = mysql_query(" select * from users where name='$name' and pass='$pass' ") or however ur selecting them while($row = mysql_fetch_assoc($sql)) { $rights = $row['user_rights']; } if ($rights == 3) { do this } else { do this } Quote Link to comment https://forums.phpfreaks.com/topic/221914-sql-if-result-s/#findComment-1148361 Share on other sites More sharing options...
Username: Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks, solved it before I read the thread though $lol = mysql_query("SELECT * FROM user WHERE password='$cookie'"); while ($row = mysql_fetch_array($lol)) { if($row['type']==="3"){ } else { die("no u"); } } Quote Link to comment https://forums.phpfreaks.com/topic/221914-sql-if-result-s/#findComment-1148372 Share on other sites More sharing options...
Maq Posted December 16, 2010 Share Posted December 16, 2010 I see, that way makes more sense for what you're trying to do anyway. Quote Link to comment https://forums.phpfreaks.com/topic/221914-sql-if-result-s/#findComment-1148407 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.