Jump to content

[SOLVED] PHP Code for an Empty mySQL Query


Hartley

Recommended Posts

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

<?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;
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.