In my script I have these caetgories for MySQL which is basically set up lke this
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); }

In reply to Looping through a subrouting by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.