I have to make a breadcrumb menu which comes database.
So made this function
function file_list($path) {
$result = array();
$q = "SELECT staticTitle,staticId,parentId FROM tbl_static_pages WHERE staticId = $path";
$run = mysql_query($q);
while($row = mysql_fetch_array($run)) {
if($row['parentId'] > 1) {
echo $row['staticTitle'];
$result = file_list($row['parentId']);
return $result; // INSERTED
}else {
return $result;
}
}
I have a database structure like this:
id | parentId | title 3 | 1 | keyword 28 | 3 | xxx 31 | 28 | business
I want to output like this business -> xxx -> keyword
I want to run this function until $row['parentId'] = 1
.
When I echo the title, I got correct result.
When I try it to store it in array, I always get single value.
How can I return an array in recursive array?