I have 3 chain select boxes that return three values from the same line of data in a table: $drop, $drop_2 and $drop_3, and I want to run a mysql query to return a value from another column from that line in the table. I can “echo” the value directly to the page, but I want to use the array value to then generate matching results from a different table in a “while” loop. I have the following set up, if anyone can tell me why it doesn’t work it would be highly appreciated!
<h1>Search Results</h1>
<table>
<tr>
<th>Name</th>
<th>Number</th>
<th>Description</th>
</tr>
<?php
$search_results = mysql_query("SELECT id_sensor FROM vehicles_new WHERE make='$drop' AND model='$drop_2' AND year='$drop_3'");
while($result = mysql_fetch_array($search_results)){
echo $result['id_sensor']; //This is displaying the value I need to use in the next query
?>
<?php
$sql = mysql_query("SELECT * FROM products WHERE id='$result'");
while($row = mysql_fetch_assoc($sql)){
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['part_id']; ?></td>
<td><?php echo $row['description']; ?></td>
</tr>
<?php
}
?>
<?php
}
?>
</table>
Thanks in advance, Joe
change this
to this