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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well upon looking it was number 2, I had no orders in the workorder table,
but here is an oddity I wonder if someone can explain if I run this simple
query:

 $query =  "SELECT * FROM admin, workorders
      WHERE   admin.UserName =   '".$_SESSION['user']."' ";

It returns adminID = 7 (my number is 20) username= tmiller (this is correct)


it's the only query I can get to return anything but it's the wrong adminID
can someone explain what can be making that happen

On Thu, Jan 29, 2009 at 2:48 PM, Shawn McKenzie <nospam@xxxxxxxxxxxxx>wrote:

> 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
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux