Hi
Hope someone can help me with this!
I'm trying to get a table of data into a multidimensional array.
The table fields are as follows; -
headline
-
text
-
startDate
-
type
-
media
-
caption
-
credit
-
Only one row of data will have a value for field "type". There will eventually be dozens of other rows.
I need to place the data into an array with the following structure; -
$array = array(
-
-
"timeline" => array(
-
"headline" => "value",
-
"text" => "value",
-
"startDate" => "value",
-
"type" => "default",
-
"asset" => array(
-
"media" => "value,
-
"caption" => "value",
-
"credit" => "value"
-
),
-
"date" => array(
-
"1" => array (
-
"headline" => "value",
-
"text" => "value",
-
"startDate" => "value",
-
"type" => "",
-
"asset" => array(
-
"media" => "value,
-
"caption" => "value",
-
"credit" => "value"
-
)
-
),
-
"2" => array (
-
"headline" => "value",
-
"text" => "value",
-
"startDate" => "value",
-
"type" => "",
-
"asset" => array(
-
"media" => "value,
-
"caption" => "value",
-
"credit" => "value"
-
)
-
)
-
);
-
-
-
All rows aside from the one where type="default" will be within "date".
I'm completely stuck with this. I've been trying to build the arrays from multiple variables, but it's just not working. I'll add that I'm still pretty new to PHP.
Any assistance you can offer with this would be MUCH appreciated!
Thank you.
2 2068 Luuk 1,047
Expert 1GB
How many/much records do you have in your table, (if you look at your example) ?
I think 6, but if that is not correct, i did not understand your problem.... ;)
The first part ('headline' - 'asset'):
This can be constructud using the MySQL query: SELECT headline, text, startdate, type, group_concat(asset)
from table
where type='default'
group by headline, text, startdate, type
After thant you have to go one level deeper, to add the 'date' fields. this is basically a repitition of the above ;)
You may want to look at my response (best answer) in this link http://bytes.com/topic/php/answers/9...-fill-template
php does not use multidimensional arrays. They use arrays within arrays. The biggest difference here is in how to access the structure of the array.
Traditional multi arrays are referenced like this array[1,1]
where as php multi arrays are referenced like this
array[1][1];
But if you are looking to do a cross-tab report, you may want to download the code example I give in the answer.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark Smith |
last post by:
I'm trying to copy data from a 1D array to a 2D array.
The obvious thing doesn't work:
int twoDee = new int;
int oneDee = new int { 1, 2 };
Array.Copy(oneDee, 2, twoDee, 2, 2);
This causes a...
|
by: chris |
last post by:
Hi there,
I created a Multidimensional array of labels
Label lblMultiArray = new Label { {Label3, LblThuTotal},
{Label4,LblFriTotal} };
Now I would like to compare the values in the array,...
|
by: epigram |
last post by:
Well, conceptually this is what I want to do. I was hoping to use an
ArrayList to build a (dynamic) array of string arrays, and then bind the
ArrayList object to a DataGrid. I can do that, but it...
|
by: BobbyS |
last post by:
I am trying to develop a multidimensional array for use of searching a very
large database. I understand the concept of one and two dimensional arrays
but this project would include up to 12 or 13...
|
by: Stephen Preston |
last post by:
Trying to load an multidimensional array into a MySQL table with columns as
follows,
level1,level2,level3,illust,item,description,partNo,qua,price,remarks,weight
,size,mass
the array first...
|
by: |
last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily
complicated than the other languages I know. I feel this is because there
aren't many good official resources out there to...
|
by: phattymatty |
last post by:
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already
been sorted in the array using a...
|
by: shailajaAdiga |
last post by:
Hi All,
there are 4 different categories which each month will bw updated. In each category(source),there are many editions. I have to display 6months updates. its like one is month array which...
|
by: Jezternz |
last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
|
by: mouac01 |
last post by:
Let's say I have this MySQL table.
Year Region Amount
2007 West 100
2007 East 200
2007 North 300
2007 South ...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |