Location: PHPKode > projects > MyDB > mydata/tbl_spl_csv.php3
<?php

set_time_limit(600);
$crlf="\n";

    require("mydatalocal.inc.php3");
    $conx = new connect;
    $conx->start(); 

    $ext = "csv";
    header("Content-disposition: filename=$table.$ext");
	header("Content-type: application/octetstream");
	header("Pragma: no-cache");
	header("Expires: 0");

	$client=getenv("HTTP_USER_AGENT");
	if (ereg('[^(]*\((.*)\)[^)]*',$client,$regs)) {
		$os = $regs[1];
		if (eregi("Win",$os)) $crlf="\r\n";
	}
  	 $sep = ";" ; 
  	 $sql_query = stripslashes($sql_query) ; 
  	 $result = mysql_db_query($db, $sql_query) ; 	 
	 while ($row = mysql_fetch_row($result)) {
	       $schema_insert = "";
	       for ($j=0; $j<mysql_num_fields($result);$j++)
	           {
	           if (!isset($row[$j])) {
	              $schema_insert .= "NULL".$sep;
	           } elseif ($row[$j] != "") {
	              $tmp_shema = ereg_replace("\n"," ",$row[$j]) ; 
                  $tmp_shema = ereg_replace("\r"," ",$tmp_shema) ; 
                  $tmp_shema = ereg_replace($sep, " ", $tmp_shema); 
	              $schema_insert .= $tmp_shema.$sep;
	           } else {
	              $schema_insert .= "".$sep;
              	}
	           }
	       $schema_insert = ereg_replace($sep."$", "", $schema_insert);
	       echo trim($schema_insert).$crlf;
	       }
  	
?>
Return current item: MyDB