Hartley Posted July 7, 2007 Share Posted July 7, 2007 Hey, I'm working on coding a system that will create a user row in a table, but first, I need the system to check initially to make sure if there is the need to do it (IE: if no row exists for said user). Right now I have it set up to pull out the following: $permissions = "SELECT forumid, memberid, setupstatus FROM user WHERE forumid = " .$_COOKIE['bbuserid']; $permquery = mysql_query($permissions); I want it to check the table to see if there is a row for someone with a specific forumid (I use vBulletin, but it only relates in this case for the cookie). IF it shows up that there is a row, I want it to set $memberstat = 2; so that I can use that variable for various other page functions. If it shows up empty, it will set it equal to 1. How can I achieve this? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/58788-solved-php-code-for-an-empty-mysql-query/ Share on other sites More sharing options...
pocobueno1388 Posted July 7, 2007 Share Posted July 7, 2007 <?php $permissions = "SELECT forumid, memberid, setupstatus FROM user WHERE forumid = " .$_COOKIE['bbuserid']; $permquery = mysql_query($permissions); if (mysql_num_rows($permquery) > 0){ $memberstat = 2; } else { $memberstat = 1; } ?> Link to comment https://forums.phpfreaks.com/topic/58788-solved-php-code-for-an-empty-mysql-query/#findComment-291690 Share on other sites More sharing options...
Hartley Posted July 7, 2007 Author Share Posted July 7, 2007 Thank you, that fixed it! Link to comment https://forums.phpfreaks.com/topic/58788-solved-php-code-for-an-empty-mysql-query/#findComment-291723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.