Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:32:13+00:00 2026-05-29T05:32:13+00:00

I have the following code which works fine however historically and again now I

  • 0

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);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:32:14+00:00Added an answer on May 29, 2026 at 5:32 am

    You should not use a separate query for each table. Instead you should use JOIN to retrieve related data from multiple tables in a single query:

    SELECT
        veh_List.col1,
        veh_List.col2,
        due_dates.col3,
        ...etc...
    FROM veh_List 
    JOIN due_dates ON veh_List.id = due_dates.id
    -- add more joins here if you need data from more tables
    ORDER BY veh_List.id DESC
    

    You should learn about the JOIN keyword and the various possibilities this provides, including understanding the difference between INNER JOIN and OUTER JOIN.

    • What is the difference between "INNER JOIN" and "OUTER JOIN"?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which works fine. However, I only want to return
I have the following code which works fine, however I wanted to know if
I have following code which works fine, however when I updated to Lion I
I have the following code, which works fine , however when I change the
At the moment I have the following code which works fine. label = new
I have the following code which works just fine when the method is POST,
I have the following code for Android which works fine to play a sound
I have code that looks like the following, which works fine for displaying the
I have the following code which works perfectly, but I want to allow access
I have the following PHP code which works out the possible combinations from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.