Solved

Insert dynamic data into defined array.

Posted on 2009-05-11
2
215 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

728 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