Re: Making a Variable from different tables with Matching Dbfields?

From: Date: Thu, 29 Jan 2009 20:48:17 +0000
Subject: Re: Making a Variable from different tables with Matching Dbfields?
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.general 
Request: Send a blank email to php-general+get-287368@lists.php.net to get a copy of this message
Terion Miller wrote: > Hi Again > > Here is the query and code I tried: > $sql = "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM > admin WHERE UserName = '" > . mysql_real_escape_string($_SESSION['user']) . "')"; > > > $result2 = mysql_query ($sql); > $row2 = mysql_fetch_assoc ($result2); > $printrow = print_r($row2); > > > > Here is my print variables--- Nothing printed with the print_r: > > $sql "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM > admin WHERE UserName = 'tmiller')" > $result2 "Resource id #6" > $row2 "" > $printrow "1" > O.K., easy: 1. There is no UserName in admin that = $_SESSION['user'] 2. Or, the AdminID that is returned for $_SESSION['user'] is not present in workorders That's why I suggested the 2 query approach the first time so that you could echo out the AdminID after the first query and then go into the db and make sure it exists in workorders. Or, if none were returned, then echo out $_SESSION['user'] and make sure it exists in admin. -Shawn

« previous php.general (#287368) next »