Created
November 20, 2021 03:43
-
-
Save viniciusmelocodes/c78029a2b7464815bd6f3bc7cede05d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Connecting to Database tempdb*/ | |
mysql_connect('localhost', 'root'); | |
mysql_select_db('tempdb'); | |
/*Executing the select query to fetch data from table tab_treeview*/ | |
$sqlqry="SELECT * FROM tab_treeview"; | |
$result=mysql_query($sqlqry); | |
/*Defining an array*/ | |
$arrayCountry = array(); | |
while($row = mysql_fetch_assoc($result)){ | |
$arrayCountry[$row['id']] = array("parent_id" => $row['parent_id'], "name" => $row['name']); | |
} | |
/*Checking is there any records in $result array*/ | |
if(mysql_num_rows($result)!=0) | |
{ | |
/*Calling the recursive function*/ | |
buildTree($arrayCountry, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment