Table
How to pull out the entire chain in a loop, for example, behind a record where id is found in parent_fid
Here is an example of my code.
$array_folderid = array(); $startfor = 0; $folderdel_id = "155"; for($i=0;$i<=$startfor;$i++) { $sql_selectfolders = "SELECT * FROM user_folders WHERE parent_fid='$folderdel_id' "; $query_selectfolders = mysqli_query($db,$sql_selectfolders) or die("Ошибка: " . mysqli_error($db)); if (mysqli_num_rows($query_selectfolders) > 0) { while ($fid = mysqli_fetch_array($query_selectfolders)) { array_push($array_folderid, $fid["id"]); } } } In this way I get this array.
Array ( [0] => 156 [1] => 159 ) But now how to repeat the cycle with this data, that is, now I need to pull out all id by the fact that it is in the array. And the depth can be unpredictable.
I myself could not solve this problem, please help.

И глубина может бить не предсказуемаin this case need recursion. If only as part of the test task - it will do. But in the working application it will slow down. - Goncharov Alexander