Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi and good day to you guys, I'm trying to create an mlm binary genealogy in php for my project, I'm stuck at creating/displaying the genealogy tree. I've search everywhere and got this code this is what I'm trying to achieve.

I'v tried to implement it using my function and so far I'm getting nowhere.

This is my code.

This is the database i'm working with.

If anyone could help me with this and explain to me why it's not working would be wonderful and very much appreciated.

What I have tried:

PHP
<div class="tree">
  <ul>
    <li>
      <div><input type="checkbox">181210-1-105547-1<br/> <button> Test Btn </button></div>
      <ul>

<?php
    $host = 'localhost';
    $name = 'mlm';
    $user = 'root';
    $pass = '';

    $dsn = 'mysql:host=' .$host .';dbname=' .$name;
    $options = array(
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_PERSISTENT => true
    );
    $conn = new PDO($dsn, $user, $pass, $options);

    function displayChildren($parent) {
        global $conn;

        $stmt = $conn->prepare('SELECT * FROM accounts WHERE sponsorUpline = ?');
        $stmt->bindValue(1, $parent);
        $stmt->execute();
        while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
            echo '<li></div><input type="checkbox">' .$row->serialNumber .'</div></li>';
            displayChildren($row->serialNumber);
        }
  }

    displayChildren('181210-1-105547-1');

?>

      </ul>
    </li>
  </ul>
</div>
Posted
Updated 13-Dec-18 17:52pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900