Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2012, 11:31 AM   PM User | #1
mesavage
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mesavage is an unknown quantity at this point
Question Array results from query

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

Last edited by mesavage; 12-18-2012 at 11:57 AM.. Reason: fixed problem
mesavage is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:36 AM.


Advertisement
Log in to turn off these ads.