Jump to content


Photo

MySQL


  • Please log in to reply
1 reply to this topic

#1 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 18 March 2006 - 10:51 PM

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

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 18 March 2006 - 11:11 PM

If you want to see all of the columns for a table:

$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;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users