views:

43

answers:

1

The fields read as 0.00 in phpMyAdmin, but when put into an array, the value is blank, is there a way to get it to show just '0'?

From my Model:

$query = $this->db->query("SELECT t1.numberofbets, t1.profit, t2.seven_profit, t3.28profit, user.user_id, username, 
PASSWORD , email, balance, user.date_added, activation_code, activated
FROM user
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS profit, COUNT( tip_id ) AS numberofbets
FROM tip
GROUP BY user_id
) AS t1 ON user.user_id = t1.user_id
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS seven_profit
FROM tip
WHERE date_settled >  '$seven_daystime'
GROUP BY user_id
) AS t2 ON user.user_id = t2.user_id
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS 28profit
FROM tip
WHERE date_settled >  '$twoeight_daystime'
GROUP BY user_id
) AS t3 ON user.user_id = t3.user_id
WHERE activated =1
GROUP BY user.user_id
ORDER BY user.date_added DESC 
LIMIT 0 , 30");

return $query->result_array();

Results in the database give : '0.00' for the seven_profit column. (column is a decimal type) with print_r($array) the array looks like '[seven_profit] => ' with no value there.

A: 

I've gone with this solution for now:

 if ($row['fieldname'] == ''){
            $row['fieldname'] = 0;
    }

Thanks

SamD
If you post your code we can try and figure out what's actually wrong, instead of you needing to hack around it. If you really don't care, accept this answer or (probably more fitting, since this doesn't actually solve the problem) delete the question
Michael Mrozek
Good advice, I've updated with more code. I hope this helps.
SamD