Re: Build Associative Array from database records

From: Date: Tue, 10 Oct 2000 20:41:52 +0000
Subject: Re: Build Associative Array from database records
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3498@lists.php.net to get a copy of this message
Miles Thompson <milesthompson@sprint.ca> wrote: > Here's what I have so far, database connection has been made .... > $arClasses = array(); > $sql = "select * from class"; > $result = mysql_query( $sql ); > while( $row = mysql_fetch_array( $result ) ) > { > $nClassKey = $row["nClassKey"]; > $cClass = $row["cClass"]; > array_push( $arClasses, $nClassKey, $cClass); $arClasses[$nClassKey] = $cClass; > } I'm not sure that I understand your problem, but isn't it this what you want to do? Lutz

« previous php.db (#3498) next »