I have a function which checks for a parent child relationship in my database and continues until no relationship is found.
It works well. I just need to paginate it as sometimes the results can get quite large and take too long to load as well as become unreadable.
How can I make this so it only loads a certain number of results and then call it again so it picks up where it left off?
function display_children($parent, $level) {
$result = checkChild($parent);
if ($result['Count'] > 0) {
foreach ($result['Items'] as $key => $item) {
echo $level . $item;
display_children($itemRepNum, $level+1);
}
}
}
The Database is structured in an adjacency list model with a structure like this:
Parent | Title
| Car
Car | Ford
Ford | Fusion
Car | Toyota
Toyota | Prius
Prius | 4door
Ford | F150
Car | BMW
...