Hi,
I am wanting to create an array that is similar to the following but from a database query.
$test = array(
"Print"=>array("Print_Brochure"=>"Brochure",
"Print_Leaflets"=>"Leaflets"),
"Web"=>array("Web_Design"=>"Design",
"Web_Develop"=>"Develop",
"Web_Amend"=>"Amend"));
The table that stores this information in the database is of the following structure:
CREATE TABLE jobtypes (
jobtype varchar(32) NOT NULL default '',
jobsubtype varchar(32) NOT NULL default '',
title varchar(64) NOT NULL default '',
datatype varchar(32) NOT NULL default '',
PRIMARY KEY (jobtype,jobsubtype,title)
) TYPE=InnoDB;
A Jobtype for example is Web, and its Subtypes are Design, Develop and Amend
I can then query this table using the following to retrieve just unique jobtypes and their subtypes
SELECT jobtype, jobsubtype FROM jobtypes GROUP BY jobtype, jobsubtype ORDER BY jobtype, jobsubtype
But i am being really slow turing this query into the array formatted as above.
And if it helps in anyway, i am wanting to create this array for a Smarty html-options, and i am using Pear DB for my database connection.
Any help would be great.
Thanks
Tim