Results 1 to 6 of 6

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.

  5. #5
    Join Date
    May 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i have a problem with my html form, anybody can help me how to solve this problem, if i enter a text without space the text message over flow to the table.

    here is my code

    <html>
    <head>
    <meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1” />
    <title>Simple HTML Form</title>
    <link rel="stylesheet" href="css.css">
    </head>
    <body>
    <!-- Script 2.1 - form.html -->
    <div id="wrapper">
    <div id="header">header section</div>
    <div id="sidebar">
    <!--start of sidebar-->
    <?php
    error_reporting(E_ALL & ~E_NOTICE);

    mysql_connect("localhost","root","");
    mysql_select_db("db_davao");

    $x = mysql_query("SELECT * FROM tbl_students1");
    ?>
    <?php
    while($row = mysql_fetch_array($x))
    {
    $id = $row['id'];
    echo "<div id='table'>";
    //echo "<br />";
    echo "<tr>";
    echo "<table border='0' style='resize:both' align='center' cellpadding='0' cellspacing='0'>";
    echo "<tr>
    <td align='right' width='100' style='fixed'>Name</td><th>:</th><td>".$y['fname']."</td>
    </tr>";
    echo "<tr>
    <td align='right'>Last Name</td><th>:</th><td>".$y['lname']."</td>
    </tr>";
    echo "<tr>
    <td align='right'>Gender</td><th>:</th><td>".$y['gender']."</td>
    </tr>";
    echo "<tr>
    <td align='right'>Age</td><th>:</th><td>".$y['age']."</td>
    </tr>";
    echo "<tr>
    <td align='right'>Comment</td><td>:</td><td><div id='comment'>".$row['comment']."</div></td>
    </tr>";
    echo " <br /> " ;
    echo "</tr>";
    echo "</table>";
    echo "</div>";
    echo " <hr> " ;


    //echo "<p align=center><a href=DisplayRecords.php>View Students List</a><p>";
    echo "</fieldset>";

    }
    ?>

    <!--end of sidebar-->
    </div>

    the output look like this

    Click image for larger version. 

Name:	image.jpg 
Views:	64 
Size:	43.8 KB 
ID:	5680

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,425
    Thanks
    16
    Thanked 416 Times in 414 Posts
    Blog Entries
    19

    Default

    Hi robertjan,

    Your post is confusing because you posted it in the PHP forum in a PHP/MYSQL related thread that is 6 years old.

    Please can you start a new thread, in the most appropriate forum, and clearly state your problem again (refer back to this thread if you need to).

    In your thread, state what you have tried already and/or a copy of the PHP scripts and MYSQL queries that are causing you problems.

    If this is an HTML/CSS related problem, please post a link to your actual website so that anyone help you can troubleshoot live in Developer Tools (F12 in most popular browsers)
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

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
  •