Solved

Insert dynamic data into defined array.

Posted on 2009-05-11
2
214 Views
Last Modified: 2013-12-12
I have a defined array, $array (see example code below). Now, data1a to data2b represent dynamic data, and there are many more data values to be inserted into this array.

For example: data1 ranges from (data1a-data1z), data2 ranges from (data2a-data2z), and so on. there are different data ranges for each set. These are defined within a database. Here is an example table

data1a, data1b, data1c, data1d
data2a, data2b
data3a, data3b, data3c
data4a, data4b, data4c, data4d, data4e
etc.

What I want to do is dynamically insert the values into the defined array without having to manually insert the values.
$array = array('data1a' => array(), 'data1b' => array(), 'data2a' => array(), 'data2b' => array());

Open in new window

0
Comment
Question by:ZeterFan411
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24357191
can you please clarify the table schema, resp. how you query the table?
assuming it's a single table/column
$array = array(); 
$sql = "select your_column from yourtable group by your_column";
$rows = mysql_query($sql);
while ($row = mysql_fetch_assoc($rows))
{
  $your_col = $row["your_column"]; 
  $array[$your_col] = array();
}

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question