show data of multiple tables?
i have 3 tables i want to show the data from them to a page.
table1 "trip"
table2 "seat"
table3 "user_informati on"
show all the data of table one which is working its showing but how can i show multiple table data any ways.
show all data of trip and seat
from user_informatio n it shows
first_name
last_name
all the tables have id with the same name.
Table (trip) show all from this
* id
* from
* to
* date
* fare
Table (seat) show all from this also
* id
* seat
Table (user_informati on) show only first_name and last_name
* first_name
* last_name
* email
* address
* city
* province
* contact_no
also show the last line which is entered in the id
here is the code im using.
i have 3 tables i want to show the data from them to a page.
table1 "trip"
table2 "seat"
table3 "user_informati on"
show all the data of table one which is working its showing but how can i show multiple table data any ways.
show all data of trip and seat
from user_informatio n it shows
first_name
last_name
all the tables have id with the same name.
Table (trip) show all from this
* id
* from
* to
* date
* fare
Table (seat) show all from this also
* id
* seat
Table (user_informati on) show only first_name and last_name
* first_name
* last_name
* address
* city
* province
* contact_no
also show the last line which is entered in the id
here is the code im using.
Code:
<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("online_bus_project", $con);
$result = mysql_query("SELECT * FROM trip, seat, user_information ORDER BY `id` DESC LIMIT 1");
echo "<table border='1'>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>From</th>
<th>To</th>
<th>Date</th>
<th>Fare</th>
<th>Seat</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['last_name'] . "</td>";
echo "<td>" . $row['from'] . "</td>";
echo "<td>" . $row['to'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['fare'] . "</td>";
echo "<td>" . $row['seat'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>

Comment