Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
| id | name | parent | description | view_cats_prod | image | org | ||
|---|---|---|---|---|---|---|---|---|
| Edit | Delete | 26 | PWC | 0 | aaa | no | store/cat/wave.jpg | 4 |
| Edit | Delete | 24 | Truck | 0 | aa | no | store/cat/truck.jpg | 5 |
| Edit | Delete | 22 | Snowmobile | 0 | aaa | no | store/cat/snow.jpg | 1 |
| Edit | Delete | 30 | Parts | 22 | aaa | no | 1 | |
| Edit | Delete | 31 | Accessories | 22 | aaa | no | 2 | |
| Edit | Delete | 32 | Off Road Bikes | 0 | Everything for dirt bikes | no | http://dtdyno.com/store/cat/cr125.jpg | 3 |
| Edit | Delete | 33 | Road Bikes | 0 | Everything for cruiser to cafe | no | http://dtdyno.com/store/cat/gsxr.jpg | 2 |
| Edit | Delete | 34 | HJC | 31 | Helmet | no | 1 | |
| Edit | Delete | 40 | Reeds | 26 | no | 1 | ||
| Edit | Delete | 41 | Intake Grates | 26 | no | 2 | ||
| Edit | Delete | 44 | Accessories | 24 | no | 2 | ||
Now parent means, that the direcotry it came from, so this is a sub categgory script, so a pair of categories would be. PWC->Reeds-> and there is much more in the datbase like I have PWC->Reeds->Demo->Pop. What I have been trying to do is, get each category and print them like this, PWC->Reeds->Demo->Pop, but how can I do this I tried something but it doesnt work, the page wont even load.
(@fer) = find_all_categories(); sub find_all_categories { $id = shift; if($id) { $sthm = $dbh->prepare("SELECT * FROM category WHERE id='$id'"); $sthm->execute or die $dbh->errstr; } else { $sthm = $dbh->prepare("SELECT * FROM category"); $sthm->execute or die $dbh->errstr; } while (@hi = $sthm->fetchrow_array) { if($hi[2] eq "0") { push(@env, @hi[0]) } else { $a = find_all_categories($slog[0]); $i += $hi[3]; $i + $a; } } push(@env,$i); return(@env); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping through a subrouting
by DamnDirtyApe (Curate) on Jul 27, 2002 at 18:11 UTC | |
|
Re: Looping through a subrouting
by vladb (Vicar) on Jul 27, 2002 at 17:59 UTC | |
|
Re: Looping through a subrouting
by rattusillegitimus (Friar) on Jul 28, 2002 at 04:32 UTC | |
|
Re: Looping through a subrouting
by Anonymous Monk on Jul 28, 2002 at 04:46 UTC | |
by dsalada (Scribe) on Jul 29, 2002 at 14:14 UTC |