0

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.

2
Contributors
3
Replies
27
Views
3 Years
Discussion Span
Last Post by keloa
0

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>

Edited by davidjennings

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.