note 43634 added to function.pg-query

From: Date: Mon, 28 Jun 2004 19:45:04 +0000
Subject: note 43634 added to function.pg-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-72069@lists.php.net to get a copy of this message
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); }; ?> ---- Manual Page -- http://www.php.net/manual/en/function.pg-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43634 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43634&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43634&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72069) next »