Hi
I'm working on this project and Ifaced this little problem,which is that I have two tables and I need them to be side by side but the problem is that I get every table in a separate line !

<center>
<table border="1" width="40%">

<tr>
    <td>
        <center><h5>order</h5></center>
    </td>
        <?php
        $sql_order = "SELECT * FROM serv WHERE username='".$username."'";
        $query = mysql_query($sql_order);
        while ($order = mysql_fetch_object($query)) {
        echo "
        <tr><td>$order->title</td></tr><br />
        ";
        }
        ?>
<tr/>
</table>
 <table border="1" width="40%"><tr>
 <td>
        <center><h5>Tracking number</h5></center>

    </td>
         <?php
        $sql_order = "SELECT * FROM serv WHERE username='".$username."'";
        $query = mysql_query($sql_order);
        while ($order = mysql_fetch_object($query)) {
        echo "
        <tr><td>$order->tracking_number</td></tr><br />
        ";
        }
        ?>
</tr>


</table>

</center>

and if there is a chance to make them in one table please tell me how.

Recommended Answers

All 3 Replies

Hi Keloa,

I think this what you are asking for? You created 2 tables only 1 was required. Also make sure you use the th and td correctly.

You may have to change the table width.

See how you get on with it
d

<?php ?>
<table border="1" width="40%">
<tr>
    <th>
        <center><h5>order</h5></center>
    </th>
    <th>
        <center><h5>Tracking Number</h5></center>
    </th>
</tr>
<tr>
    <td>
        <?php
        $sql_order = "SELECT * FROM serv WHERE username='".$username."'";
        $query = mysql_query($sql_order);
        while ($order = mysql_fetch_object($query))
        {
             echo "$order->title";
        }
        ?>
     </td>
     <td>
        <?php echo "$order->tracking_number";  ?>
    </td>
<tr/>
</table>

I'm sorry but this code is out of the loop :

 <?php echo "$order->tracking_number";  ?>

so it won't be right !(The variable isn't defined!).
it gave me this error :
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/tt/work/myorders.php

I found a way ^_^
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.