curtis_b Posted March 22, 2006 Share Posted March 22, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/5537-2-simultaneous-queries/ Share on other sites More sharing options...
kenrbnsn Posted March 23, 2006 Share Posted March 23, 2006 You're missing the end semi-colon on the previous line.Ken Quote Link to comment https://forums.phpfreaks.com/topic/5537-2-simultaneous-queries/#findComment-19821 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.