tags:

views:

93

answers:

4

Hi All,

I need to display a table in a web page. The data from the table comes from database which I can query using mysql php library. I am looking for a template/example of how to come up with a nice looking table (I am not good at front end design :().

Any link/example/references will be appreciated. Thank you.

+3  A: 

Something like this if you're just wanting the front-end design.

jackbot
+1  A: 

Here is an example on how to read a MySQL table into a HTML table. And no, it does not look nice.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html>
    <head>
        <title>Read values from MySQL</title>
    </head>
    <body>
        <?
            mysql_connect($db_host,$db_user,$db_pw);
            mysql_select_db($db_name);
        ?>
        <table border="1">
            <tbody>
                <?
                    $result = mysql_query("SELECT firstname, lastname FROM persons")
                        OR die(mysql_error());
                    while($row = mysql_fetch_assoc($result)) {
                        echo '<tr><td>' . $row['firstname'] . '</td><td>' . $row['lastname'] . '</td></tr>';
                    }
                ?>
            </tbody>
        </table>
    </body>
</html>
Simon
A: 

Assuming your rows are an array of PHP objects...

echo '<table>';
foreach ($rows as $row) {
    echo '    <tr>';
    echo '        <td>'.$row->column_1.'</td>';
    // etc.
    echo '    </tr>';
}
echo '</table>';
henasraf