I have a function that I loop to to build an url. what I need is to get the result in a single string. This is the code.
// Create URL for accesories
function create_url($id) {
global $db_categories;
// Select category sublevels
$sql_cat="SELECT parent_id, seo_id FROM $db_categories WHERE category_id = '".$id."'";
$catres = mysql_query("$sql_cat") or die (mysql_error());
while($selected_cat = mysql_fetch_array($catres)) {
$cat_seo = $selected_cat['seo_id']. "/";
$output .= $cat_seo;
create_url($selected_cat['parent_id']);
}
return $output;
}
// Call function
$result_cat = create_url($cat["category_id"]);
echo $result_cat;
This work fine if I use echo and will output (I only use $depth to track the results)
category1/
category2/
category3/
etc...
The problem is that I don't know how to return the result into a single string instead of echo it. When I use return it only outputs the first result. like this.
category1/
I want the return to output.
category1/category2/category3/
I can't for my life find a solution for this.
Thank's