Re: Re: Arrays

From: Date: Wed, 28 Apr 2004 11:02:07 +0000
Subject: Re: Re: Arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-184857@lists.php.net to get a copy of this message
Thanks man...it is working ----- Original Message ----- From: "Torsten Roehr" <roehr@zilleon.com> To: <php-general@lists.php.net> Sent: Wednesday, April 28, 2004 1:25 PM Subject: [PHP] Re: Arrays > >"Fannehh Adevarap" <fannehh@adevarap.ro> wrote in message > news:001701c42d08$c3e79960$5600a8c0@fannehh... > >I have a problem with arrays. > > > >I have this script: > > > >$query = "SELECT model_name, brand_name FROM products WHERE > product_id='$product_id'"; > > > >$result = mysql_query($query) or die("error in query - > $query -".mysql_error()); > > > >while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > > > >foreach ($line as $element) { > >$jelement[] = $element; > > > >} > >} > > Do this: > > $modelNames = array(); > $brandNames = array() > > while(list($model_name, $brand_name) = mysql_fetch_row($result)) { > > $modelNames[] = $model_name; > $brandNames[] = $brand_name; > } > > Regards, Torsten > > > > >i want each element to be stored in a different array. > > > >For ex: If i print now the array $jelement i have: > > > > model_name1-brand_name1 > > model_name2-brand_name2 > > ......... > > > >I want 2 arrays: array1 will contain [model_name1,model_name2, ....] and > array2 [brand_name1,brand_name2......] > > > > > >How can i do that? > > > >Thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#184857) next »