Re: Whats the correct syntax for using query results in a new query
| From: | Dan Shirah | Date: | Tue, 03 Mar 2009 20:45:42 +0000 |
| Subject: | Re: Whats the correct syntax for using query results in a new query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289187@lists.php.net to get a copy of this message | ||
>
> I'm trying to use the AdminID that returns from query #1 in the WHERE
> AdminID = AdminID from Query 1
Okay, I think I understand what you are trying to do.
//query 1
$query1 = "SELECT UserName, AdminID FROM admin
WHERE Retail1 = 'YES'";
$result1 = mysql_query ($query1) ;
while ($row1 = mysql_fetch_row($result1)){
$admin_id = $row1['AdminID'];
//query 2
$query2= "SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM workorders WHERE AdminID =
$admin_id";
$result2 = mysql_query ($query2) ;
$end_result = mysql_fetch_row($result2);
echo $end_result['WorkOrderID'];
echo $end_result['CreatedDate'];
}