Hi,

Here is what I use:

     
      /* setup file structure */
           
         $csv_output = '"cust_id","accnt"';
         $csv_output .= "\015\012";
     
         while($row = mysql_fetch_array($cat1_q)) {
               $csv_output .= '"'.$row['cust_id'].'","'.$row['accnt'].'"';
               $csv_output .= "\015\012";
               }

         $size_in_bytes = strlen($csv_output);
           
     
      // no cache
            header("Cache-Control: no-store, no-cache, must-revalidate");
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            header("Pragma: no-cache");
      // Fiel related headers
            header("Content-type: application/vnd.ms-excel");
            header("Content-disposition:  attachment; filename=customer_PW_chng" .
            date("Y-m-d").".csv; size=$size_in_bytes");
            print $csv_output;
            mysql_free_result($cat1_q);
            exit;
      }
     

Sincerely,
Mike
-- 
Mike Brandonisio          *    Web Hosting
Tech One Illustration     *    Internet Marketing
tel (630) 759-9283        *    e-Commerce
[EMAIL PROTECTED]    *    http://www.jikometrix.net

     JIKOmetrix - Reliable web hosting


On Apr 26, 2006, at 10:33 AM, Pete Holsberg wrote:

> I'm sure it has to be verys imple but I have not been able to 
> figure it out. :-(
>
> I would like to have some PHP code that will connect to an existing 
> database and download it to a CSV file.
>
> Can anyone point me to some example or tutorial?
>
> Thanks.
>
>
>
>
>
> The php_mysql group is dedicated to learn more about the PHP/MySQL 
> web database possibilities through group learning.
> Yahoo! Groups Links
>
>
>
>
>
>
>
>



The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning.



SPONSORED LINKS
American general life and accident insurance company American general life insurance company American general life
American general mortgage American general life insurance Computer internet security


YAHOO! GROUPS LINKS




Reply via email to