Re: getting values by a joints mysql query

From: Date: Thu, 20 Jun 2002 04:12:06 +0000
Subject: Re: getting values by a joints mysql query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103072@lists.php.net to get a copy of this message
Hi, There is no need to reference the item as U.Name or Groups.GID Simply do something like this: $result = mysql_query($query); if ($result) { if (mysql_num_rows($result) > 0) { while ($data = mysql_fetch_array($result)) { $Name = $data["Name"]; $Title = $data["Title"]; $GID = $data["GID"]; print $Name; print $Title; print $GID; } } else { printf("ERROR: No rows found<BR>"); } } else { $error = mysql_error(); printf("ERROR: %s<BR>", $error); } Hope this helps. "Michael P. Carel" <mikecarel@teamglac.com> wrote in message news:014f01c2180d$a9fd81c0$4301a8c0@teamglac.com... > Hi to all, > > Im having problem in getting the the result values in my cross joint query. > Here's my query: > > $query=("Select U.Name, U.Title, G.Groups from Users as U, Groups as G where > U.Id='$Id' "); > $result=mysql_query($query); > $data=mysql_fetch_array($result); > $Name= $data[U.Name]; > $Title = $data[Title]; > $GID = $data[Groups.GID]; > > print $Name; > print $Title; > print $GID; > > I dont have any printed results here. But if i query the two table one by > one i can have the printed result. > Please help! > > > > Regards, > Mike >

« previous php.general (#103072) next »