|
Posted by Colin Fine on 10/07/06 17:05
toffee wrote:
> Hi all,
>
> i have several php files which each run a different SELECT query and
> displays the data in a table. I would like to create an option to export the
> table to excel and one route i would like to go down is creating a single
> export.php file with an excel header; and basically it would read the sql
> query stored in a session; and just create a spreadsheet from the results.
> the problem is each query yields a different number of columns, so what php
> code would tell it to select all fields for every row rather than specifying
> each field one by one?
>
> I hope this makes sense to you.
>
> Kind regards
>
> T
>
>
Assuming you're using MySQL,
mysql_fetch_row returns a row as an enumerated array
mysql_fetch_array returns an enumerated or associative array
mysql_fetch_object returns an object.
In each case, you do not need to know in advance how many fields will be
returned. And if you use the associative array or the object you can get
at the names of the fields as well.
Does this answer your question?
Colin
Navigation:
[Reply to this message]
|