Results 1 to 4 of 4

Thread: Display data of multiple tables into page?

  1. #1
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Display data of multiple tables into page?

    Display data of multiple tables into page?
    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 Code:
    <?php
    $con 
    mysql_connect("localhost","root","passwo...
    if (!
    $con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("
    online_bus_project", $con);

    $result = mysql_query("SELECT FROM tripseatuser_information ORDER BY `idDESC 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);
    ?>


    i want this to show data in a straight line in one table?


    here are the data list.

    Table trip

    id
    from
    to
    date
    fare

    table seat

    id
    seat

    table user_information

    this table has information about user which contains user contact no email address and so on but i want to show only first_name and the last_name





    also show the last data entered in table ORDER BY `id` DESC LIMIT 1
    Last edited by Snookerman; 05-17-2009 at 05:41 PM. Reason: added [php] tags

  2. #2
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    any one?????

    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

  3. #3
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    You need to have fields that link the tables together, they can then be "joined" for 'querying'.

    This link shows a simple example of this:
    http://www.astahost.com/info.php/mys...es_t12815.html

  4. #4
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Correct, first step is to add a Column to the tables seat AND trip.

    You should call this column "CustomerID" and then put that customers ID in those columns to they can be linked and have a matching field to be grouped/pulled by.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •