I have the following code which works fine however historically and again now I want to (if possible) add a third select statement to collect further information and return it in my while loop i.e. as $row2. Is there any way I can do this or will I have to rehash my code completely to make it work?
Any help or guidance will be gratefully received. Current code is as below:
mysql_select_db("jbsrint", $con);
$result = mysql_query("SELECT *, DATE_FORMAT(Date_Registered, '%d-%m-%Y') AS Date_Registered, DATE_FORMAT(Date_Last_MOT, '%d-%m-%Y') AS Date_Last_MOT, DATE_FORMAT(Date_Last_Tax, '%d-%m-%Y') AS Date_Last_Tax FROM Veh_List ORDER BY ID DESC");
$DUE_DATES = mysql_query("SELECT *, DATE_FORMAT(MOT_DUE_DATE, '%d-%m-%Y') AS MOT_DUE_DATE, DATE_FORMAT(Date_Tax_Due, '%d-%m-%Y') AS Date_Tax_Due FROM due_dates ORDER BY ID DESC");
echo "<table border='1'>
<tr>
<th>Vehicle Reg</th>
<th>Vehicle Make</th>
<th>Vehicle Model</th>
<th>Vehicle Colour</th>
<th>Date Registered</th>
<th>Date Of Last MOT</th>
<th>MOT Due</th>
<th>Date Of Last Tax</th>
<th>Tax Due</th>
<th>Vehicle Driver</th>
<th>Vehicle Driver Tel</th>
</tr>";
while($row = mysql_fetch_array($result) and $row1 = mysql_fetch_array($DUE_DATES))
{
echo "<tr>";
echo "<td class=\"td1\">" . $row['Vehicle_Reg'] . "</td>";
echo "<td >" . $row['Vehicle_Make'] . "</td>";
echo "<td class=\"td1\">" . $row['Vehicle_Model'] . "</td>";
echo "<td>" . $row['Vehicle_Colour'] . "</td>";
echo "<td class=\"td1\">" . $row['Date_Registered'] . "</td>";
echo "<td>" . $row['Date_Last_MOT'] . "</td>";
echo "<td class=\"td1\">" . $row1['MOT_DUE_DATE'] . "</td>";
echo "<td>" . $row['Date_Last_Tax'] . "</td>";
echo "<td class=\"td1\">" . $row1['Date_Tax_Due'] . "</td>";
echo "<td>" . $row['Vehicle_Driver'] . "</td>";
echo "<td class=\"td1\">" . $row['Vehicle_Driver_Tel'] . "</td>";
}
echo "</tr>";
echo "</table>";
mysql_close($con);
?>