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)

Did you know?Explore Trending and Topic pages for more stories like this.
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 Like 35 Dislike
Previous forums Next forums
Other forums

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

Material xxx does not exist in plant xxx
Dear All,

I am working for a steel project which is repetitive manufacturing.

Weird problem with SELECT command..Help!
Hi!

It seems I'm having a really weird problem with SQL SELECT command....I have table into a

Preventing SQL Injection
I have a question about SQL Injection, In some of our code we use this: view plaincopy to clipboa

Sequencing or queuing parallel process
Scenario is as follows
There is one parent process say P1 and 4 child processes say A B C D

Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

Problem assigning value to variable in "IF" function
Does this script makes sense? I am trying to take the value that is set to "authenticat" a

disabling a button server-side then re-enabling client-side breaks button postback
I have a tabbed container and a button (not in the container) on a page. If the first tab is selecte

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash