Forum Moderators: coopster

Message Too Old, No Replies

select data from multiple database tables and show them to page table?

         

Meer

10:22 am on May 17, 2009 (gmt 0)

10+ Year Member



i have 3 tables i want to show the data from them to a page.

table1 "trip"
table2 "seat"
table3 "user_information"

show all data of trip and seat table but from user_information it shows

first_name
last_name

all the tables have id with the same name.

here is the code im using.

<?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);
?>

Meer

4:09 pm on May 17, 2009 (gmt 0)

10+ Year Member



any one?

Meer

8:35 pm on May 17, 2009 (gmt 0)

10+ Year Member



any one have solution to this?

Meer

8:37 pm on May 17, 2009 (gmt 0)

10+ Year Member




here are the tables.

Table (trip) show all from this
* id
* from
* to
* date
* fare

Table (seat) show all from this also
* id
* seat

Table (user_information) show only first_name and last_name
* id
* first_name
* last_name
* email
* address
* city
* province
* contact_no