Re: Write custom column names to query result file



Joe Gazda wrote:
>
> I'm a relative newbie to PHP, but have been able to put together some
PHP
> code to generate a CSV/XLS file from a Query result. Now, I would
like to
> include custom column names instead of the MySQL column table names.
I know
> that there are codes to generate tabs and carriage returns, but can't
find
> anything about including "commas" in a string to output to the file
to
> separate the custom field names.

Just replace "\t" with ",". That's it.

> I'd appreciate some help with a line of code to insert those custom
> column names like:
>
> First Name | Last Name | DOB | etc.

OK, right now you have:

> for ($i = 0; $i < $fields; $i++) {
> $header .= mysql_field_name($export, $i) . "\t";
> }

Just replace it with

$header = "First Name,Last Name,DOB,etc.";

Cheers,
NC

.



Relevant Pages

  • Re: Compiled PHP Questions
    ... > eyes so that I can deploy custom web-applications on a customer's ... That is the problem with PHP. ... PHP was developed as an open-source ... compiler produces is identical to the one cached PHP code has. ...
    (alt.php)
  • Re: Help with php5-curl scripting
    ... Looking for sample php5-curl script to use as guide to custom my own from. ... try asking in a PHP specific mailing list of forum. ...
    (freebsd-questions)
  • Custom 404 page works on one server, not another
    ... working on one of our secondary sites on the production server. ... between sandbox and production are identical, as are their IIS settings (I ... It makes no difference whether I change the custom 404 settings to be ... It's also obvious to me that it's not php, ...
    (microsoft.public.inetserver.iis)
  • Choosing a host based on their PHP "security" measures
    ... for this - running a wide variety of PHP applications. ... as a module, so on a host running CGI, I CANNOT get permalinks, pretty ... php configuration directives in custom .htaccess files (and not custom ...
    (comp.lang.php)