PHP / MySQL Associative Multidimensional Array:
Posted on
16th Feb 2014 07:03 pm by
admin
Hello.
I have data in a MySQL Table that adheres to the below: (note, no index, could add if necessary)
group~~~~~setting~~~~~value
1~~~~~~~~~Babble~~~~~Yeah, sure
1~~~~~~~~~Dabble~~~~~No, rather not
2~~~~~~~~~Crab~~~~~~~Maybe
3~~~~~~~~~Flab~~~~~~~Nah, not today
I want to query this and add it to an associative multidimensional array.
I have the following:
Line number On/Off | Expand/Contract $getem = array(array()); while ($row = mysql_fetch_assoc($result)) { $getem[][] = $row['group']; $getem[][] = $row['setting']; $getem[][] = $row['value']; }
Of course, this is not associative. I thought if I changed $getem = array(array()); to $getem = array( array('group', 'setting', 'value') );, then it would be associative, but this isn't working.
My ultimate goal is this:
I have a second table in which the 'group' of the above table is a FK to the index of the second table. The end result, once processed and matched using PHP, is to print out the following:
Group Name 1
~~~Babble~~~Year, sure
~~~Dabble~~~No, rather not
Group Name 2
~~~Crab~~~~Maybe
Group Name 3
~~~Flab~~~~Nah, not today
Am I on the right track? You don't need to write the code for me, I'm just looking for a little direction.
Thanks
No comments posted yet
Your Answer:
Login to answer
283
35
Other forums
foreach iterator
Hi Guys
Does the foreach loop have an inbuilt iterator ?
split values
I have values that are returned to me in this format:
name=>test,age=>49
Inserting 100x and 100y coordinates in mysql table - easy
Is there a way to insert this data into a mysql table named 'map' with the fields: 'x int 3' , 'y in
Problem with an browser game.
Hello,i just joined that great forum and i got php prob,its kinda freaky...anyway i got browser game
How to make URL loads only on login
On my page, when a user login he's redirects to user_home.php. I made it also to open the chat scree
how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy
Open browser page depending on XML results
Hello,
I have some PHP code that sends webbased from data to an external url ( in the form of
Pass sql into pl/sql and create RMAN duplicate script.
Hi,
I'm new to pl/sql and I'm trying to write a script that will generate some RMAN comma
Warning: session_start() [function.session-start]: Cann.....
hi, can someone help me with this? I keep getting this error....
Warning: session_start() [fu
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500