Hi, I would like to get the fieldnames from a mysql query, and add them into an array,
and from that get the results from the array and add them into a variable as a string.
The (relatively cheap piece of) code, that I've written so far looks like this:
$numfields=mysql_num_fields($result);
$numrows=mysql_num_rows($result);
$time=time();
$tabledata=mysql_fetch_array($result);
$col="#3399CC";
$type="hidden";
$count=0;
while ($count < $numfields)
{
echo("<tr bgcolor=$col>");
//alternate the colors in the table cell
$col=( gettype($count/2)=="double" ? "#3399CC":"#3399FF");
echo("<td>" . mysql_field_name($result,$count) . "</td>\n");
$fname= mysql_field_name($result,$count);
/the data is being displayed in the form here/
echo("<td> <input name=$fname type=$type value=" . $tabledata[$count] . "></input></td></tr>\n");
$type="text"; $count++;
}
Now what I want to do (not sure if it could be done) is to extract the array of field names and add them to a variable so that the variable would probably look something like this: $a = "fielname1, fieldname2, fieldname3";...
Can anyone help me?
Thanks in advance.