I have the following function and wish to return my own array of results, but for some reason, I keep only receiving one result.
PHP Code:
$chid = 4
$lvl = 1
$status = array();
$data = array( 'date', 'partner', 'reward', 'receipt', 'spent' );
$qry = "SELECT t1.amt,t1.chid,t1.pid,t1.date,t1.receipt,t3.tname,t3.kickback_level1,t3.kbtype1,t3.kblvl1_active
FROM transactions AS t1
LEFT JOIN partners AS t3 ON t3.id = t1.pid
WHERE t1.chid = $chid
AND dodbid > 0
AND t1.pid > 1";
$result = mysql_query($qry,$this->connection);
if(!$result || mysql_num_rows($result) <= 0)
{
$status["fail"] = 0;
} else {
while ($row = mysql_fetch_assoc($result)) {
$status[] = $row;
}
}
foreach($status as $row) {
$data["date"] = $row["date"];
$amount = (float)$row["amt"];
$data["partner"] = $row["tname"];
$data["receipt"] = $row["receipt"];
$data["spent"] = $row["amt"];
if ($row["kblvl1_active"] == 'y') {
if ($row["type"] == 'vpt') {
$data["reward"] = ($row["kickback_level1"] * $total);
}
if ($row["kbtype1"] == 'ppt') {
$ppt = ( ($row["kickback_level1"] * $amount) / 100 );
if ($lvl == 0) {
$data["reward"] = ($ppt * 25) / 100;
} elseif ($lvl == 1) {
$data["reward"] = ($ppt * 27.5) / 100;
} elseif ($lvl == 2) {
$data["reward"] = ($ppt * 30) / 100;
} elseif ($lvl == 3) {
$data["reward"] = ($ppt * 35) / 100;
} elseif ($lvl >= 4) {
$data["reward"] = ($ppt * 40) / 100;
}
}
}
}
$status = $data;
return $status;
Can anyone please help me out with this problem?
Edit: Solved the problem, it seems I needed to post the problem for me to see the solution. Had everything backwards, working now