Jump to content
Sign in to follow this  
Max45

How to show my result in the vertical table /

Recommended Posts

Posted (edited)

The following code is showing my result horizontally and I want to show them vertically 

$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id = $id"; 
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    echo "<table align=\"center\">;
    <tr>
    <th>ID</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Email</th>
    <th>Join Date</th>
    </tr>";
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo 
        "<tr>
        <td>".$row["id"]."</td>
        <td>".$row["fname"]."</td>
        <td>".$row["lname"]."</td>
        <td>".$row["email"]."</td>
        <td>".$row["reg_date"]."</td>
        </tr>";
    }
    echo "</table>";
} 

Any idea?

Thanks in advance

Edited by Max45

Share this post


Link to post
Share on other sites

Not going to code this, but off the top of my head I would use Flex-box and not a table. Set it up to display as you have it above (horizon.) . Then set the flex order by row to instantly create a vertical table.

Share this post


Link to post
Share on other sites
3 hours ago, NotSunfighter said:

Not going to code this, but off the top of my head I would use Flex-box and not a table. Set it up to display as you have it above (horizon.) . Then set the flex order by row to instantly create a vertical table.

You mean like this?

th, td { text-align: left display: flexbox; flex-order: 1; }

th, td {
        text-align: left
     display: flexbox;
    flex-order: 1;
}

 

Share this post


Link to post
Share on other sites
13 hours ago, NotSunfighter said:

Stop using tables. Use divs for the cells. Put them in a container and flex that.

Thaaaaaaaaaaaaaaaaaaaankyou , You really save my time for this advice.

It worked 

Thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.