I managed to display the referrals of level 1 like this:
<?php $reqfilleul = $db->query("SELECT * FROM parrain WHERE '".$cle."' = idParrain ")->fetchAll(); ?>
<h5>Premier niveau</h5>
<?php if (empty($reqfilleul)) { ?>
<p class="alert alert-danger">Vous n'avez pas encore de filleul</p>
<?php }else { ?>
<?php $i=1; ?>
<?php foreach ($reqfilleul as $result): ?>
<div class="row">
<div class="d-flex key-feature align-items-center p-3 rounded shadow mt-4">
<div class="flex-1 content ms-3">
<h4 class="title mb-0">
<?= $result['prenom']; ?>
<?= $result['nom']; ?>
</h4>
<p class="text-muted mb-0">
<?= $result['email']; ?>
</p>
</div>
</div>
</div>
<?php endforeach; ?>
<?php }?>
?
Now i want to display the level 2 and 3
Please help
My Answer:
To display the referrals of level 2 and 3 in a multi-level marketing system, you will need to modify your SQL query to fetch the referrals of the referrals (level 2) and the referrals of the referrals of the referrals (level 3). Here's an example of how you can achieve this:
Level 2 Referrals:
php
// Fetch level 2 referrals
$reqfilleul_level2 = $db->query("SELECT * FROM parrain WHERE idParrain IN (SELECT id FROM parrain WHERE idParrain = '".$cle."')")->fetchAll();
?>
Deuxième niveau
Vous n'avez pas encore de filleul de niveau 2
= $result['prenom']; ?>
= $result['nom']; ?>
= $result['email']; ?>
Level 3 Referrals:
php
// Fetch level 3 referrals
$reqfilleul_level3 = $db->query("SELECT * FROM parrain WHERE idParrain IN (SELECT id FROM parrain WHERE idParrain IN (SELECT id FROM parrain WHERE idParrain = '".$cle."'))")->fetchAll();
?>
Troisième niveau
Vous n'avez pas encore de filleul de niveau 3
= $result['prenom']; ?>
= $result['nom']; ?>
= $result['email']; ?>
Make sure to replace the SQL queries with the appropriate table and column names in your database. This code will display the level 2 and level 3 referrals based on the parent ID provided in the variable `$cle`.
Rate this post
3 of 5 based on 2860 votesComments