Jump to content

Simple display query


woolyg

Recommended Posts

Noobie Q here, but I just couldnt find it anywhere..!

Say if I ran a query that called all rows from a table:

 

	$display = mysql_query("SELECT * FROM table");
$show = mysql_fetch_array($display); 

And that returned

 

ID    Name    Surname  Level

1    John      Smith        10

2    Barry    Manilow      8

3    James    Brown        6

 

 

...how would I form the PHP to display all of the above info in bold? Can someone help? I'm embarrassingly noobalicious.

Link to comment
Share on other sites

i don't understand how you know how to make your post text bold, but not your html...

 

<?php
        $sql = "
                SELECT
                        *
                FROM
                        your_table
        ";

        $query = mysql_query($sql) OR die(mysql_error());

        echo "
                <table border=\"1\">
                        <tr><td>ID</td><td>Name</td><td>Surname</td><td>Level</td></tr>
        \n";

        while($row = mysql_fetch_array($query)){
                echo "<tr><th>{$row['id']}</th><th>{$row['name']}</th><th>{$row['surname']}</th><th>{$row['level']}</th></tr>\n";
        }
        echo "</table>\n";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.