RE: [PHP] SQL Functions

From: Date: Tue, 10 Aug 2004 14:50:46 +0000
Subject: RE: [PHP] SQL Functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193281@lists.php.net to get a copy of this message
Hi, > In order to get all of the data back you are going to have to loop > through it and return the array so that it will be available for > manipulation. Hmm.. I suspected this might be the case. I have modified my functiona bit: function selectRows( $sql ) { $count = 0; $results = mysql_query( $sql, DB::connect() ); while ( $data = mysql_fetch_array( $results ) ) { foreach ( $data as $name => $value ) { $array[$count][$name] = $value; } $count++; } return $array; } Then I am doing a foreach on the returned $array: foreach ( $jack as $data ) { echo $data['id']; } Seems to work ok. Thanks for the information. -Dan Joseph

« previous php.general (#193281) next »