PHP / Mysql Question

Hey peeps,

I’m trying to get some data from a mysql database. I’m doing a SELECT * FROM db, Storing the columns into an array and trying to print out the data associated with the columns. Here is my code. For some reason it stops at the first field set which is the Id. I could just do two separate while loops but would rather not. Any help is appreciated - Thanks.

[php]
while($fieldinfo=mysqli_fetch_field($result))
{
$row = $result->fetch_assoc();
$columnName[$columnCount] = $fieldinfo->name;
// Testing
echo $columnName[$columnCount]; // Echo’s the column names to the screen.
echo $row[$columnName[$columnCount]]; // Displays the id but nothing else.
echo $columnCount; // Dsplays results 0 - 33
echo ‘
’;
$columnCount++;

}
[/php]

Since I never done this, all I can do is point you in the right direction: http://php.net/manual/en/mysqli-result.fetch-field.php

That is the place I would go to if seeking on how to do this.

Sponsor our Newsletter | Privacy Policy | Terms of Service