hi all, i'm working on database with a lot of category...
here i example for category that i like to create Computer Computer/Motherboard Computer/Motherboard/AMD Computer/Motherboard/Intel Computer/Drive & Storage Computer/Driver & Storage/SATA Computer/Driver & Storage/ATA Computer/Driver & Storage/ATA/7200 RPM/ Computer/Driver & Storage/ATA/10000 RPM/ Elektronik Elektronik/Television Elektronik/Television/CRT Elektronik/Television/CRT/14 " and go on so i use on mysql table table Category --------------------------------------- | id_cat | nama_category | id_parent | --------- ----------------- ----------- | 001 | Computer | TLCAT | | 002 | Motherboard | 001 | | 003 | AMD | 002 | | 004 | Intel | 002 | | 005 | Drive & Storage | 001 | | 006 | SATA | 005 | | 007 | ATA | 005 | | 008 | 7200 RPM | 007 | | 009 | Elektronik | TLCAT | | 010 | 10000 RPM | 007 | | 011 | Television | 009 | | 012 | CRT | 011 | | 013 | 14" | 012 | --------- ----------------- ----------- this is the script #!/usr/bin/perl use DBI; $dbh = DBI->connect("DBI:$dbtype:$dbname",$dbuser,$dbpass); $sth = $dbh->prepare("select * from Category where id_parent = 'TLCAT';"); $sth->execute; while(@DataCat = $sth->fetchrow_array() ) { $tl_name = @DataCat[1]; ONE: while() { $sth2 = $dbh->prepare("select * from Category where id_parent='@DataCat[2]';"); $sth2->execute; while(@DataCat2 = $sth2->fetchrow_array() ) { $tl_name .= "/@DataCat2[1]"; print "$tl_name/@DataCat[1]"; } $sth2->finish; last ONE: } } $sth->finish; $dbh->disconnect; The OUTPUT is Komputer/Komputer/Komputer Komputer/Komputer/Electronik/Komputer Electronik/Komputer/Electronik Electronik/Komputer/Electronik/Electronik Please help me with the logic.... i've been doing with while and for still like that Thx before -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>