Jump to content


2 simultaneous queries?

  • Please log in to reply
1 reply to this topic

#1 curtis_b

  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 22 March 2006 - 09:53 PM

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

#2 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 March 2006 - 02:46 AM

You're missing the end semi-colon on the previous line.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users