Jump to content

Display data from MySQL with PHP without knowing the field name


phppaper

Recommended Posts

$query = 'SELECT * FROM users';
$result = mysql_query($query, $connection);
$fieldCount = mysql_num_fields($result);
for ($i = 0; $i < $fieldCount; ++$i) {
    echo mysql_field_name($result, $i), ', ';
}

 

Outputs:

id, username, password, email_address

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.