note 43634 deleted from function.pg-query by tomsommer

From: Date: Mon, 28 Jun 2004 19:54:35 +0000
Subject: note 43634 deleted from function.pg-query by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72072@lists.php.net to get a copy of this message
Note Submitter: ---- very useful code you can insert your text file into table records are separated by new line fields in a record are separated by commas <?php // by http://www.jetevents.pl $fcontents = file( "data.txt" ); while ( list( $line_num, $line ) = each( $fcontents ) ) { $array=explode(",",$line); $str=''; $a=0; foreach ($array as $z) { $str.=($a++ ? ',' : '')."'".addslashes(trim($z))."'"; }; $sql= "INSERT INTO table VALUES ($line_num,$str)"; $result=pg_Exec($conection,$sql); }; ?>

« previous php.notes (#72072) next »