note 19040 added to control-structures.foreach

From: Date: Wed, 13 Feb 2002 20:05:35 +0000
Subject: note 19040 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-26581@lists.php.net to get a copy of this message
I've tried various ways to pull out data and simply displaying it on my browser -->for example: for each thing in array write thing --------------------- <? $conn = pg_pconnect ("dbname=mydatabase"); $result = pg_exec ($conn, "select * from pamtest"); $numfields = pg_numfields ($result); $numrows = pg_numrows ($result); For ($i = 0; $i < $numfields ; $i++){ printf("<th bgcolor='silver'>%s</th>", pg_fieldname ($result,$i)); } print "</tr>\n"; For ($i=0; $i < $numrows; $i++){ $array = pg_fetch_row($result,$i); print "<tr>\n"; Foreach($array as $value){ echo "<td>".$value."</td>\n"; } print "</tr>\n"; } ?> Hope this helps someone. -- http://www.php.net/manual/en/control-structures.foreach.php http://master.php.net/manage/user-notes.php?action=edit+19040 http://master.php.net/manage/user-notes.php?action=delete+19040 http://master.php.net/manage/user-notes.php?action=reject+19040

« previous php.notes (#26581) next »