Re: Arrays from forms

From: Date: Sun, 04 Feb 2001 17:06:29 +0000
Subject: Re: Arrays from forms
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38112@lists.php.net to get a copy of this message
"Jamie" <jssmith@echidna.stu.cowan.edu.au> wrote: > $results = mysql_query("SELECT option_type, code FROM options WHERE > code='000' ORDER BY option_type",$db); > mysql_fetch_array($results); > // From what understand I should have an array some thig like this: > // ("Size"=>"A4" , "Size" => "A3", > "Size"=>"A5", "Colour"=>"Red", etc..); According to your SQL statement that doesn't appear to be true. According to your SQL statement you'll return two fields: option_type and code. > $types = array_values($results); > // OK so now I think I have an array like this: > // ("A4" , "A3", "A5", "Red", etc..); > while ($type =array_pop($types)){ > echo $type."<br>"; > } I'd avoid using array_values() and array_pop(). Simply do this: while ( $row = mysql_fetch_array( $result ) ) { $option_type = $row[option_type]; $code = $row[code]; echo "$option_type $code<br>"; } Hopefully that'll be enough to get you going. -- Steve Werby COO 24-7 Computer Services, LLC Tel: 804.817.2470 http://www.247computing.com/

« previous php.general (#38112) next »