Jump to content

Archived

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

turbocueca

MySQL

Recommended Posts

Hello, can someone tell me how can I output all fields of a row in a mysql db using php? and then write.

Share this post


Link to post
Share on other sites
If you want to see all of the columns for a table:

[code]$query = "SHOW COLUMNS FROM tablename";
$result = mysql_query($query);

$html = '
    <table>
        <tr>';
    
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    if ($row['Key'] == "PRI") {
        $primarykey = $row['Field'];
    }
    
    $html .= "<th>" . $row['Field'] . "</th>";
}

$html .= '</tr>
    </table>';

echo $html;[/code]

Share this post


Link to post
Share on other sites

×

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.