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
2 decima places & How to reload my page
Hello There,
How do i put full-stop (.) after second figure from behind? ie if i have 123456
get multiple rows
Hi I want to get multiple rows from a db
I am using this for the db query
Code: public
A problem with my GD class
Hello,
I created a nice (and simple for now) GD class.
The problem is , it works great on
How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........
PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator
Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a
Creating a unique 'control panel' for each user
Hi there,
I'm thinking of designing a site that will allow users to sign up and have their ow
Problem with coding MySQL query
I'm having heaps of trouble getting one of my PHP/MySQL queries to work for some reason (and the fun
Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..
I need to pull data for clien
Is it possible to stop reservation creation in PM Order?
Hi All,
Is it possible to stop reservation creation in PM Order?
Thanks in adv