Jump to content


Mr-Chidi

Member Since 20 May 2008
Offline Last Active Yesterday, 11:55 PM

Topics I've Started

notification badge in php

Yesterday, 02:15 PM

hi all,

how can i create a notification badge in php eg like when i have a new message, it will display on the nav indicating new message and the number of messages.

thanks


Reward Logic

06 January 2015 - 04:10 AM

I have a referal system. I want to have a reward for referring someone. I allocate a certain amount for the referal system (lets say $50). At level 1, nothing is given until you start referring people and the person(s) starts using the program.

On level 2 you earn 9%($4.5 of $50)
on level 3 you earn 27%
On level 4 you earn 64%


How do i go about this bearing in mind that a level 2 or 3, eventually becomes level 1 if he starts inviting people and those he invited starts using the program.


Thanks
 


Value not echoing

25 December 2014 - 05:33 AM

Hello guys,

I want to get the values of 3rd level of my referral but it did not echo any value but if i put the ref id directly on the code, it will echo the values. why is it so? or am i doing it the wrong way?

in my database i have a table test_referral

id    acct_name    ref_id    refer_id
1    john        J1234    0
2    bull        B3456    J1234
3    doe        D5567    J1234
4    frank        F7788    J1234
5    jimmy        J9990    J1234
6    tommy        T6784    F7788
7    tom        T9988    F7788
8    girly        G8866    D5567
9    fred        F0099    J9990
10    ronaldo        R7722    B3456

thanks
 

$stmt= $pdo->query("SELECT * FROM test_referral WHERE acct_name='Chidi Okafor'");
$parent = $stmt->fetch(PDO::FETCH_LAZY);
echo "<ul><li>";
echo $parent['acct_name'];
$ref_id  = $parent['ref_id'];
echo "</li><ul>";



$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_id'");
$child_count = $stmt->rowCount();
while($child = $stmt->fetch(PDO::FETCH_LAZY)){
echo "<li>";
echo $child['acct_name'];
$ref_ids  = $child['ref_id'];
echo "</li>";
}

//$reff = "F7788";
//$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$F7788'");
$stmt= $pdo->query("SELECT * FROM test_referral WHERE refer_id='$ref_ids'");
$child_count2 = $stmt->rowCount();

while($children = $stmt->fetch(PDO::FETCH_LAZY)){
echo "<ul><li>";
echo $children['acct_name'];
echo "</li></ul>";

}

Adding Date Interval

23 December 2014 - 01:53 AM

Hi all.

In my database, i have a column recurring which is derived from a multiple option

form field with values: Weekly, Bi-Monthly, Monthly, Quarterly, Half Yearly and

Yearly. I want to have as next due the current date plus the recurring value. eg

current date = 2014-11-24
recurring = monthly
next due = current date + recurring (in the next due will be 2014-12-24)

so i did:

$stmt = $pdo->query("SELECT recurring, due_date FROM $table");
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $recur = $row['recurring'];
    $date_due = $row['due_date'];
}
$weekly = "Weekly";
$bi_monthly = "Bi-Monthly";
$monthly = "Monthly";
$quarterly = "Quarterly";
$half_yearly = "Half Yearly";
$yearly = "Yearly";

if(strcmp($recur, $weekly) == 0){
    $recurs = "7 DAY";
}elseif(strcmp($recur, $bi_monthly) == 0){
    $recurs = "14 DAY";
}elseif(strcmp($recur, $monthly) == 0){
    $recurs = "1 MONTH";
}elseif(strcmp($recur, $quarterly) == 0){
    $recurs = "3 MONTH";
}elseif(strcmp($recur, $half_yearly) == 0){
    $recurs = "6 MONTH";
}elseif(strcmp($recur, $yearly) == 0){
    $recurs = "1 YEAR";
}

$stmt = $pdo->query("SELECT ADDDATE('$date_due', INTERVAL $recurs) as nex_due FROM

$table");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$nex_due = $row['nex_due'];


$stmt = $pdo->prepare("SELECT * FROM $table ORDER BY trans_id DESC");
$stmt->execute();
$num_rows = $stmt->rowCount();
    
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    // Print out the contents of each row into a table
echo "<tr><td>";
echo $row['trans_ref'];
echo "</td><td>";
echo $row['acct_num'];
echo "</td><td>";
echo ucwords($row['payee']);
echo "</td><td>";
echo ucwords($row['company']);
echo "</td><td>";
echo $row['acct_no'];
echo "</td><td>";
echo number_format($row['amt'],2);
echo "</td><td>";
echo $row['purpose'];
echo "</td><td>";
echo $row['recurring'];
echo "</td><td>";
echo $row['due_date'];
echo "</td><td>";
echo $nex_due;
echo "</td><td>";
echo "<strong>".$row['status']."</strong>";
echo "</td><td>";
echo "<strong>".$row['pay_status']."</strong>";
echo "</td><td>";
}

The problem is that it's giving me as next due the value of the first row even

when the recurring is different!

Undefined variable: pdo

21 December 2014 - 12:41 AM

Hi guys.

 

why is my function error: undefined varable pdo?

 

Thanks

 

function referralCount($uid,$reflvl)
{

$stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$uid'");
$nusrref1 = $stmt->rowCount();
//$arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY);

$reflvl1=$nusrref1;
$ttlreflvl2="0";
$ttlreflvl3="0";

for ($i=0; $i<$nusrref1; $i++)
{
$arrusrref1 = $stmt->fetch(PDO::FETCH_LAZY);
    $stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref1[0]'");
    $nusrref2 = $stmt->rowCount();
    //$arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY);
    $ttlreflvl2=$ttlreflvl2+$nusrref2;


        for ($j=0; $j<$nusrref2; $j++)
        {
        $arrusrref2 = $stmt->fetch(PDO::FETCH_LAZY);

        $stmt= $pdo->query("SELECT * FROM scraffiliateusr WHERE usrinvby='$arrusrref2[0]'");
        $nusrref3 = $stmt->rowCount();
        //$arrusrref3 = $stmt->fetch(PDO::FETCH_LAZY);

        $ttlreflvl3=$ttlreflvl3+$nusrref3;
        }
}
$reflvl2=$ttlreflvl2;
$reflvl3=$ttlreflvl3;
if($reflvl=='1')
{
return($reflvl1);
}
elseif($reflvl=='2')
{
return($reflvl2);
}
elseif($reflvl=='3')
{
return($reflvl3);
}

}

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com