Is there anyway I can use a SQL statement to pull in column titles? Essentially I have one table with 60 columns titled 1-60, and I also have another table that has two columns and 60 rows….I will populate the the first column with numbers 1-60 and the second column with each number's respective column title. Is there anyway to utilize $col["title"] = " "; to do this?
1 Answers
If you don't specify columns (->set_columns), it will load all.
You can create columns in loop using followind sample code.
Sample code to make fields array …
$sql = $sql . " LIMIT 1 OFFSET 0";
$result = mysql_query($sql);
$numfields = mysql_num_fields($result);
for ($i=0; $i < $numfields; $i++) // Header
{
$f[] = mysql_field_name($result, $i);
}
Your Answer