kemnet Posted May 20, 2012 Share Posted May 20, 2012 Hello Forums. I have this query $mt = $this->db->prepare('SELECT id,type,rigFROM table WHERE form_name=?'); $mt->bind_param("s",$form_name); $mt->execute(); $mt->bind_result($id,$type,$rig); This works fine... but i want to say incase the current date is => expires date(which is a column) write expired or not expired to another column like this $mt = $this->db->prepare('SELECT id,type,rig,CASE WHEN CURDATE( ) >= `expires` THEN 'Expired'ELSE 'Not Expired'END AS status FROM table WHERE form_name=?'); $mt->bind_param("s",$form_name); $mt->execute(); $mt->bind_result($id,$type,$rig,$status); This code works fine in PHP admin but when i pull it onto my webscripts it doesnt seem to work...would love if someone could point out my error..thanks Link to comment https://forums.phpfreaks.com/topic/262839-select-case-help/ Share on other sites More sharing options...
Illusion Posted May 21, 2012 Share Posted May 21, 2012 That might be due to inappropriate single quotes. Try putting sql query in double quotes as you already have literal strings in single quotes with in query or use concatenation operator to build the query. Link to comment https://forums.phpfreaks.com/topic/262839-select-case-help/#findComment-1347189 Share on other sites More sharing options...
kemnet Posted May 21, 2012 Author Share Posted May 21, 2012 like thiS? ("SELECT id,type,rig,CASE WHEN CURDATE( ) >= `expires` THEN 'Expired'ELSE 'Not Expired'END AS status FROM table WHERE form_name=?"); Link to comment https://forums.phpfreaks.com/topic/262839-select-case-help/#findComment-1347190 Share on other sites More sharing options...
Illusion Posted May 21, 2012 Share Posted May 21, 2012 Yes. Does it work ? Link to comment https://forums.phpfreaks.com/topic/262839-select-case-help/#findComment-1347199 Share on other sites More sharing options...
kemnet Posted May 21, 2012 Author Share Posted May 21, 2012 actually what i did to get it to work was \'Expired\' thanks for setting me on the write path Link to comment https://forums.phpfreaks.com/topic/262839-select-case-help/#findComment-1347242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.