I have a table in my database that looks like this :
#
# Structure de la table `img_cat`
#
CREATE TABLE img_cat (
id int(10) unsigned NOT NULL auto_increment,
id_parent int(10) unsigned default NULL,
nom text,
link char(1) NOT NULL default 'n',
child char(1) NOT NULL default 'n',
lang int(4) NOT NULL default '1',
description text,
galerie char(1) NOT NULL default 'n',
PRIMARY KEY (id)
) TYPE=MyISAM;
#
# Contenu de la table `img_cat`
#
INSERT INTO img_cat VALUES (1, 0, 'dir_01', 'n', 'y', 1, '', 'n');
INSERT INTO img_cat VALUES (2, 0, 'dir_02', 'n', 'n', 1, '', 'y');
INSERT INTO img_cat VALUES (3, 1, 'dir_01_01', 'n', 'n', 1, '', 'y');
INSERT INTO img_cat VALUES (4, 0, 'dir_03', 'n', 'y', 1, '', 'n');
I need to create a function to order the results of a the request : "select * from img_cat"
i need to have arrays that are like this one
$array_"parent_level"(lev1=>'1',lev2=>'3',levels=>"number of levels")
for each entries in the table where galerie=y, I need do have a table that stores each parent level until the level's parent_id = 0
In each table, I need to store the number of levels
I know how to do it with a recursiv function that queries the database for each level but I would like to have a function that does only one request in the database and then orders the request results in arrays...
It's hard to explain and my english isn't really goos. I hope someone will understand what I mean!!!!