Jump to content

2 simultaneous queries?


curtis_b

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.