Jump to content


This topic is now archived and is closed to further replies.


2 simultaneous queries?

Recommended Posts

I have two tables. The main table has only unique invoice numbers, the second related table allows multiple instances of invoice numbers.

I want to have my web page list one row from the main table and then any related rows from the 2nd table before moving on to the next item on the main table.

I assumed I could to a typical select query with a while loop to grab from the main table, which works fine, but inside of the loop I wanted to add the 2nd query which grabs related rows from the 2nd table. It doesn't work. My code is below, can anyone explain to me how I can do this?

//populate a div full of jobs currently out for proof
$query = "SELECT * FROM proofs where Response_y_or_n='n'";
$result = mysql_query($query) or die(mysql_error());

while ($row = mysql_fetch_array($result)){
$row['Invoice_Number'] = $Invoice_Number

$query2 = "SELECT * FROM proofs_versions where Invoice_Number = '$Invoice_Number'";
$result2 = mysql_query($query2) or die(mysql_error());

echo '<span class="invoice_number">'.$row['Invoice_Number'].'</span><span class="customer_orgname">'.$row['Customer_OrgName'].'</span><span class="description"> '.$row['Description'].'</span><span class="designer_name">'.$row['Designer_Name'].'</span><span class="response_target_datetime">'.$row['Response_Target_DateTime'].'</span><span class="customer_email"><a href="mailto:'.$row['Customer_Email'].'">'.$row['Customer_Email'].'</span></a><br>';

while ($row2 = mysql_fetch_array($result2)){echo $row2['Filename'].'<br>';}


The error it's giving me is "Parse error: syntax error, unexpected T_VARIABLE in d:\home\sites\7cpco.com\wwwroot\proofs\overview.php on line 41"

line 41 is the $query2=......... line

Share this post

Link to post
Share on other sites
You're missing the end semi-colon on the previous line.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.