ozzwald1972 Posted March 21, 2013 Share Posted March 21, 2013 Hi, I have limited knowledge of Mysql, but understand the following script starts at the beginning of the DB and will work its way through. <code>public static function getNextLead(){ $lead_res = Database::get()->data->query("SELECT `lead_id` FROM `" . DATABASE_TBL_LEADS . "` WHERE `lead_disposition` IS NULL AND (`lead_timeout` IS NULL OR `lead_timeout` < NOW()) AND (`lead_locked` = '0000-00-00 00:00:00' OR `lead_locked` IS NULL) AND `lead_active` = '1' LIMIT 1"); $lead_num = $lead_res->numRows(); if($lead_num == 1){ </code> I want to access the leads WHERE `lead_disposition` IS NULL AND (`lead_timeout` IS NULL) AND (`lead_locked` IS NULL) AND `lead_callcount` IS '0' AND `lead_active` = '1'and then access the other available leads. I can read code, but do not know the correct syntax, so i am going round round in circles. Many thanks for your help in advance Quote Link to comment https://forums.phpfreaks.com/topic/275967-how-to-sort-order-of-info-from-db/ Share on other sites More sharing options...
ozzwald1972 Posted March 21, 2013 Author Share Posted March 21, 2013 UPDATE: I tired this code in MYPHPHADMIN and it worked: SELECT `lead_id` FROM `ssc_leads` WHERE `lead_disposition` IS NULL AND (`lead_timeout` IS NULL OR `lead_timeout` < NOW()) AND (`lead_locked` = '0000-00-00 00:00:00' OR `lead_locked` IS NULL) AND `lead_active` = '1' ORDER BY `lead_id` DESC LIMIT 1 This works so the last record is displayed, how ever when i put the code into the script, it doesnt make any difference. Quote Link to comment https://forums.phpfreaks.com/topic/275967-how-to-sort-order-of-info-from-db/#findComment-1420139 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.