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
https://forums.phpfreaks.com/topic/48728-simple-display-query/
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
https://forums.phpfreaks.com/topic/48728-simple-display-query/#findComment-238838
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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