Hi every one I have two tables (say xx and yyy) with both sharign aa common filed, which is part_number. I wonder if you would help me correct this mysql_query statement: $pdf = mysql_query( " SELECT * FROM pn_quark WHERE part_number = $row['part_number'] ") or die(mysql_error()); Code (markup): The complete php code is ass follows: I have looked at the syntax of the above command but with no luck. Please help before I pull my remainign hair out. $partnumber=$_REQUEST['partnumber']; print("<font size=\"3\" face=\"Arial\" color=\"#002675\" >" ); $result = mysql_query(" SELECT * FROM xxxxx WHERE part_number LIKE '$partnumber%' ") or die(mysql_error()); $row = mysql_fetch_array($result); [COLOR="Red"]$pdf = mysql_query( " SELECT * FROM yyyyy WHERE part_number = $row['part_number'] ") or die(mysql_error()); [/COLOR] $rowpdf = mysql_fetch_array($pdf); echo "<table border='1' align='center'> "; echo "<tr> <th>Part Number</th> <th>Description</th><th >Price (£)</th><th>Pdf</th> </tr>"; // keeps getting the next row until there are no more to get echo "<tr ><td align=\"center\">"; echo $row['part_number']; echo "</td><td align=\"center\">"; echo $row['disc']; echo "</td><td align=\"center\">"; echo $row['price_each1']; echo "</td><td align=\"center\">"; echo $rowpdf['page_number']; echo "</td></tr>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table if((substr_count($row['part_number'], "-") < 2) && (substr_count($row['part_number'], "+") ==0) && (substr_count($row['part_number'], " ") ==0 ) && (strpos($row['part_number'], "-") < 7) ) { echo "<tr ><td align=\"center\">"; echo $row['part_number']; echo "</td><td align=\"center\">"; echo $row['disc']; echo "</td><td align=\"center\">"; echo $row['price_each1']; echo "</td><td align=\"center\">"; echo $rowpdf['page_number']; echo "</td></tr>"; } } echo "</table>"; if (!isset($_POST['submit'])) { } else { if (mysql_num_rows($result) ==0) { echo"No such part number, please try again"; } } } print("</font>"); ?> Code (markup): Just a note about what it is supposed to do: T1) The user enters a part number ( or part of a part number) 2) I look into all occurences ( of part_number in first table) that start with the entered data. 3) Then I wish to find the page number in the 2nd table for every single part_number that is found from the first search, to do a 2nd search and display the page number (from the 2nd table). Thanks in advance.
try replacing it with this code $pdf = mysql_query( " SELECT * FROM pn_quark WHERE part_number ='" . $row['part_number'] . "'") or die(mysql_error()); mind the single quotes
Not sure what you are asking, something like this? $pdf = mysql_query(" SELECT * FROM x, y WHERE x.part_number = y.part_number = {$row['part_number']} ") or die(mysql_error()); Code (markup):
Hi buldozerceto Many thanks for your help. It worked first time. I suppose I can figure out what you have done.
Hi There is one problem though. In that I was expecting the $rowpdf to ba an array, but it only diplays just the one value, and not any other. $row = mysql_fetch_array($result); Code (markup): is an array and I was expecting the $rowpdf = mysql_fetch_array($pdf); Code (markup): to be an array also, but it just holds the first value it finds. Any ideas will be most welcome. thx