Hi!
im been sitting with this for a wail…
trying to make a list of the sections after id and parnetid.
like this… [indent]‘id 0’ About
‘id 1’ Service[indent]‘id 2’ Service 1 ‘parent id 1’[indent]‘id 3’ Service 1.1 ‘parent id 2’[/indent]‘id 4’ Service 2 ‘parent 1’[/indent]‘id 5’ Contact
[/indent] here is the code i’ve been working whit (all day);
$result = $connector->query('SELECT ID, name, parentid FROM fm_sections ORDER BY ID');
while ($row = $connector->fetchArray($result)) {
if ($row['parentid'] == '0') {
echo '</br>
Section id; <b>'.$row['ID'].'</b>
Section Name; <b>'.$row['name'].'</b>
Section parent id; <b>'.$row['parentid'].'</b><br />';
}
$result_child = $connector->query('SELECT ID, name, parentid FROM fm_sections');
while ($row_child = $connector->fetchArray($result_child)) {
if ($row['parentid'] > '1') {
if ($row['ID'] == $row_child['parentid']) {
echo '
<blockquote>
Section id; <b>'.$row['ID'].'</b>
Section Name; <b>'.$row['name'].'</b>
Section parent id; <b>'.$row['parentid'].'</b>
</blockquote>';
}
}
}
}
mysql tabel (if needed);
--
-- Table structure for table `fm_sections`
--
DROP TABLE IF EXISTS fm_sections;
CREATE TABLE fm_sections (
ID int(4) unsigned NOT NULL auto_increment,
name varchar(20) default NULL,
parentid int(4) default '0',
PRIMARY KEY (ID)
) TYPE=MyISAM AUTO_INCREMENT=23 ;
--
-- Dumping data for table `fm_sections`
--
INSERT INTO fm_sections VALUES (10, 'News', 0);
INSERT INTO fm_sections VALUES (11, 'About', 0);
INSERT INTO fm_sections VALUES (16, 'Deltakarar', 0);
INSERT INTO fm_sections VALUES (14, 'TingOgTang', 0);
INSERT INTO fm_sections VALUES (17, 'Bandene', 16);
INSERT INTO fm_sections VALUES (18, 'Dirigent', 17);
INSERT INTO fm_sections VALUES (19, 'Stykker', 17);
INSERT INTO fm_sections VALUES (20, 'Komponist', 19);
hope someone can help me with this…
tanx…
philip