Re: Array driving me nuts - THANKS!

From: Date: Wed, 29 Nov 2000 21:37:13 +0000
Subject: Re: Array driving me nuts - THANKS!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-27887@lists.php.net to get a copy of this message
----- Original Message ----- From: "Miles Thompson" <milesthompson@sprint.ca> To: "Jon Rosenberg" <php@columbusinteractive.com>; "PHP General List" <php-general@lists.php.net> Sent: Wednesday, November 29, 2000 8:38 AM Subject: Re: [PHP] Array driving me nuts > Why not just use the array returned from the result set? Mysql_fetch_array > returns an associative array with key, value pairs, so you can fetch elements > using the name of your key, in this case the field name. > > // all your preliminary code > // get the number of rows here for display if you wish > // then use the search_result handle. > while ($results_returned = mysql_fetch_array( $search_result )) > { > //table formating stuff as appropriate > echo "$results_returned['_fname'] : $results_returned['_lname'] > ... <br>"; > //increment your row counter if you want to use it for display > //table formatting stuff > } > > You may want to shorten some variable names to help readability, but that's > another discussion. > > Also keep in mind, while creating your "WHERE" clause, is that if the variable > is empty it doesn't exist. > > Regards - Miles Thompson >

« previous php.general (#27887) next »