Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP MySQL - Multiple Select Queries returned in while loop
    primarykey
    data
    text
    <p>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?</p> <p>Any help or guidance will be gratefully received. Current code is as below:</p> <pre><code>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 "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;Vehicle Reg&lt;/th&gt; &lt;th&gt;Vehicle Make&lt;/th&gt; &lt;th&gt;Vehicle Model&lt;/th&gt; &lt;th&gt;Vehicle Colour&lt;/th&gt; &lt;th&gt;Date Registered&lt;/th&gt; &lt;th&gt;Date Of Last MOT&lt;/th&gt; &lt;th&gt;MOT Due&lt;/th&gt; &lt;th&gt;Date Of Last Tax&lt;/th&gt; &lt;th&gt;Tax Due&lt;/th&gt; &lt;th&gt;Vehicle Driver&lt;/th&gt; &lt;th&gt;Vehicle Driver Tel&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result) and $row1 = mysql_fetch_array($DUE_DATES)) { echo "&lt;tr&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row['Vehicle_Reg'] . "&lt;/td&gt;"; echo "&lt;td &gt;" . $row['Vehicle_Make'] . "&lt;/td&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row['Vehicle_Model'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['Vehicle_Colour'] . "&lt;/td&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row['Date_Registered'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['Date_Last_MOT'] . "&lt;/td&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row1['MOT_DUE_DATE'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['Date_Last_Tax'] . "&lt;/td&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row1['Date_Tax_Due'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['Vehicle_Driver'] . "&lt;/td&gt;"; echo "&lt;td class=\"td1\"&gt;" . $row['Vehicle_Driver_Tel'] . "&lt;/td&gt;"; } echo "&lt;/tr&gt;"; echo "&lt;/table&gt;"; mysql_close($con); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload