Re: Help with arrays

From: Date: Fri, 12 Mar 2004 13:38:43 +0000
Subject: Re: Help with arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-180247@lists.php.net to get a copy of this message
I have tried several combinations, including foreach, do whiles. This works when i submit the values one by one, but when i try to automatize it it wont work. Thanks mysql_select_db($database_MBTTIENDA, $MBTTIENDA); $query_prefsname = "SELECT Pref_name FROM mtmbt_prefs"; $prefsname = mysql_query($query_prefsname, $MBTTIENDA) or die(mysql_error()); $row_prefsname = mysql_fetch_assoc($prefsname); mysql_select_db($database_MBTTIENDA, $MBTTIENDA); $query_prefsvalue = "SELECT Pref_value FROM mtmbt_prefs"; $prefsvalue = mysql_query($query_prefsvalue, $MBTTIENDA) or die(mysql_error()); $row_prefsvalue = mysql_fetch_assoc($prefsvalue); // merging them into the new array $MTMBT foreach($row_prefsvalue as $i => $v) { $MTMBT[$row_prefsname[$i]] = $v; } // printing result foreach($MTMBT as $k => $v) { echo "\$MTMBT[$k] => $v.<br>"; } echo "the end lets see the results"; print_r($MTMBT); echo "<br>"; echo $MTMBT['Titulo']; <snip - snip> <memoimyself@yahoo.com.br> escribió en el mensaje news:40517AC2.11794.1B7033@localhost... > Hello Elliot, > > On 11 Mar 2004 at 23:55, Elliot J. Balanza wrote: > > > I need to make a query to a MySQL database that only has two fields, name & > > value. That I can do. > > > > Then I need to store the values i receive in an array in the form of: > > > > $variable['name'] = value; > > > > But haven't been able to do it neither with a foreach nor with a do while... > > Can anyone please assist me? > > Assuming you've read the introductory sections of the PHP manual and are not trying to > get other people to spend their time on your project so that you won't need to spend > yours, please show us your code so that we can help you spot the problem. > > Erik

« previous php.general (#180247) next »