Jump to content

How to sort order of info from DB


ozzwald1972

Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.