Welcome Guest, Not a member yet? Register   Sign In
Processing SQL Results
#4

[eluser]harpster[/eluser]
Thanks that was very helpful especially the use of the IF statement in the query. I changed my query from this

Code:
$query = $this->db->query("SELECT * FROM cycling WHERE user = $user_id ORDER BY ridedate");

to this, but I did have to add single quotes around the time & date formatting '%c %d' to get it error free.

Code:
$query = $this->db->query("SELECT location, id, distance, ridetime, avespeed,
                                    maxspeed, avehr, maxhr, avecad, notes, zone,
                                    rating, location, ridename,
                                    IF(`group`=0,'','Y') AS `group`,
                                    IF(org=0,'','Y') AS org,
                                    IF(weight=0.0,'',weight) AS weight,
                                    IF(avecad=0,'','') AS avecad,
                                    IF(maxhr=0,'',maxhr) AS maxhr,
                                    IF(avehr=0,'',avehr) AS avehr,
                                    DATE_FORMAT(ridedate, '%c/%d') AS ridedate,
                                    DATE_FORMAT(ridetime, '%l:%i:%s') AS ridetime
                                    FROM cycling
                                    WHERE user = $user_id
                                    ORDER BY ridedate");


Messages In This Thread
Processing SQL Results - by El Forum - 03-04-2011, 12:12 PM
Processing SQL Results - by El Forum - 03-04-2011, 05:11 PM
Processing SQL Results - by El Forum - 03-04-2011, 09:40 PM
Processing SQL Results - by El Forum - 03-07-2011, 09:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB