[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");