Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: apelmahmud
- * Date: 02/04/2017
- * Time: 3:24 PM
- */
- $serverName = 'localhost';
- $userName = 'root';
- $pass = '';
- $dbname = 'HR';
- $name ="orko";
- $con = new mysqli($serverName,$userName,$pass,$dbname);
- if($con->connect_error){
- die("connect fail");
- }
- // $sql = 'select * from employees where employee_id = 3000';
- function tree($parent){
- global $con;
- $sql = "select * from employees where manager_id =$parent";
- $result = $con->query($sql);
- if ($result->num_rows > 0) {
- echo "<ul>";
- while ($row = $result->fetch_assoc()) {
- echo "</li>";
- echo $row['EMPLOYEE_ID']." ".$row['FIRST_NAME']."<br>";
- echo "</li>";
- tree($row['EMPLOYEE_ID']);
- }
- echo "</ul>";
- }
- }
- //tree(3);
- tree(1);
- //before if conditon
- // <ul>
- // </li>2 Diana<br></li>
- // <ul>
- // </ul>
- // </li>10 Nancy<br></li>
- // <ul>
- // </li>11 Daniel<br>
- // </li>
- // <ul></ul>
- // </ul></ul>
- //after add if condition
- // <ul>
- // </li>2 Diana<br></li>
- // </li>10 Nancy<br></li>
- // <ul>
- // </li>11 Daniel<br></li>
- // </ul>
- // </ul>
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement