Echo array in one row

Hi to All,

I am new in the forum as new member. I have been using this forum for a long time although did not require posting anything as I could find lot of info from your contributions to this valuable forum. Today I have a question for which I could not find an answer.

Question is…

I have a MySQL category and subcategory entries as follows:

 CatID  ParentID     Name     
 3177     0             first 
 3178     0             second 
 3179     0             third 
 3180     0             fourth
 3181     0             fifth
 3182     0             sixth
 3189     0             seventh
 3190     0             eigth
 3196     3181        ten     
 3198     3196        twenty           
 3199     3196        thirty           
 3200     3196        forty     
 3203     3196        fifty       
 3206     3181        sixty           
 3207     3196        seventy            
 3208     3199        eighty     

I can read query from above in array.

I need to know the following if I use the GET method to post the CatID.
I want to echo all subcategories (in descending order based on CatID) up to the first Parent in one row with hyphens as follows:
i.e. (based on CatID 3208) echo --> eighty-thirty-ten-fifth

Any suggestions to write the PHP code to display it?
I will be able to use it in my own function.

Thank you.