Dynamic column title utilizing SQL

QuestionsDynamic column title utilizing SQL
Matt Kern asked 6 years ago

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
Abu Ghufran answered 6 years ago

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

16 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!