Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP nested while loops problem 1

Status
Not open for further replies.

eva0212

Programmer
Jun 30, 2008
8
Hi,
I have a problem that in looping of two queries.
My code as below:
<?
$queryWorkOrderStatus = "SELECT * FROM " . $table['work_order'] ." WHERE
lower(workOder_status) LIKE LOWER('%" . $keyword . "%') AND site_pkid = $filterId";
$resultsWorkOrderStatus = $database->query($queryWorkOrderStatus);
$results_WorkOrderStatus = $resultsWorkOrderStatus->fetchRow();
while($results_WorkOrderStatus = $resultsWorkOrderStatus->fetchRow()){
$query = "SELECT * FROM " . $table['work_request'] ." WHERE pkid = ".$results_WorkOrderStatus[request_pkid]." AND site_pkid = $filterId";
?>

Suppose after select $queryWorkOrderStatus , that might have few record.
Then running the $query just will get one of the pkid only.
What should i add and what the mistake of my code.

Thanks.
 
Why not simplify things and do something like:

Code:
$sql = "
SELECT *.a, *.b FROM 
$table['work_order'] a, $table['work_request'] b 
WHERE lower(a.workOder_status) LIKE LOWER('%" . $keyword . "%') AND a.site_pkid = $filterId AND
a.request_pkid = b.pkid AND 
b.site_pkid = $filterId";

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top