Re: SQL Functions

From: Date: Tue, 10 Aug 2004 15:19:08 +0000
Subject: Re: SQL Functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193288@lists.php.net to get a copy of this message
From: "Dan Joseph" <djoseph@nocheck.com> > > 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; > } Change that to: $array = array(); $results = mysql_query( $sql, DB::connect() ); while($data = mysql_fetch_array($result)) { $array[] = $data; } return $array; No need to loop through $data. ---John Holmes...

« previous php.general (#193288) next »