| | |
result multiple table data?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
i have 3 tables i want to show the data from them to a page.
table1 "trip"
table2 "seat"
table3 "user_information"
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_information it shows
first_name
last_name
all the tables have id with the same name.
here is the code im using.
table1 "trip"
table2 "seat"
table3 "user_information"
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_information it shows
first_name
last_name
all the tables have id with the same name.
here is the code im using.
PHP Syntax (Toggle Plain Text)
<?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); ?>
Last edited by m-hrt; May 16th, 2009 at 8:39 pm.
Look into mysql joins or using the where clause and table aliases.
Ex.
Ex.
PHP Syntax (Toggle Plain Text)
SELECT * FROM trip t,seat s,user_information u WHERE t.id = s.id AND t.id = u.id
•
•
•
•
Look into mysql joins or using the where clause and table aliases.
Ex.
PHP Syntax (Toggle Plain Text)
SELECT * FROM trip t,seat s,user_information u WHERE t.id = s.id AND t.id = u.id
that's not working??? its not showing any error but its also not showing the result all the tables are blank
check this?
PHP Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM trip t,seat s,user_information u WHERE t.id = s.id AND t.id = u.id"); 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);
Last edited by m-hrt; May 17th, 2009 at 11:47 am.
![]() |
Similar Threads
- How to show Table data in Texbox (VB.NET)
- download table data from mysql (PHP)
- want to populate the listbox with msaccess database table data (Visual Basic 4 / 5 / 6)
- way to inserting data into a MYSQL table data in an ordered way (MySQL)
- How will display multiple table records in crystal report (VB.NET)
- Error in display multiple table record in datagrid (VB.NET)
- Read multiple column data from SQL query ( 1 row ) (ASP.NET)
- Populate Listboxes with table data (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: Help MySQL5 and PHP5 billing system
- Next Thread: Database records and xml
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess 301 access ajax apache api array beginner binary broken cakephp checkbox class cms code compression cron curl database date directory display download dropdown dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla limit link login loop mail md5 menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search secure select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video votedown web xml youtube






