Jump to content

Is this possible??


Aesop

Recommended Posts

Hi there,

Ok picture this;  in one mysql table we have 4 names aka our brokers. 

*table "brokers"
-------------------------------------------
bid | bname |
-------------------------------------------
1  | joe
2  | john
3  | mary
4  | joann
-------------------------------------------

On the website we have a contact form in which we treat anyone who contacts us as a lead.  I have a seperate table for storing those leads and the date they contacted us.  Now what I would like to do is setup some kind of query and php conditional statement that auto-assigns each new lead to the broker who is next in line based off of which broker received the last lead.  So if mary got the last one, then joann would be next.  This is the basic overview of the table structure I have;

table "leads"
-------------------------------------------
lid | lname |  bid (the join) | ldate
-------------------------------------------
1  | elvis presley | 3 | 2006-12-01 08:15:00
2  | paris hilton | 4 | 2006-12-01 09:24:45
3  | barney rubble | 1 | 2006-12-04 21:14:45
4  | carmen electra | 2 | 2006-12-05 16:20:00
-------------------------------------------

Is this doable or am I going to be manually assigning them?
Link to comment
Share on other sites

When you assign a lead, just record it in a table that has:
broker_id, lead_id, date_assigned

When it's time to assign your next lead you can choose the person who has last received a lead with:
[code]$sql = "SELECT broker_id FROM lead_assigns WHERE 1 ORDER BY date_assigned LIMIT 1";[/code]

You will have to make sure that when adding rows to this table to insert if the broker doesn't already exist and to update if they do.  Otherwise it gets a little trickier.
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.