Jump to content

Recommended Posts

So I am programming a lead generation site.

 

All my leads come in from a form and the info is dumped into a database.

 

Now I have several vendors signed up on the site, and what I want to do, is to have each lead go to 2 vendors. That is easy, I can do that no problem.

 

This is what I am trying to tackle and I dont know exactly how I should go about this in PHP. I have more than 2 vendors, right now I have about 26, and I want the leads to be spread out amongst the vendors evenly as they come in.

 

How can I do this so it doesnt always just go to the same vendors? Your thoughts are appreciated

I was thinking I could set a column under the vendor name and with a default value of 0, and if they get a lead it sets the value to 1, and as leads come it it sends the lead to the next to vendors that have it set to zero... and if all vendors have the value set to 1, it will reset the value to 0 again.

 

Would that work?

I was thinkin it would look something like this maybe... sorry real code mixed in with sudo code.

 

$query = "SELECT * FROM vendors WHERE available='0';
$results = mysql_query($query) or die (mysql_error());
$num_rows = mysql_num_rows($results);
if($num_rows > 0)
{
$counter = 0; //counter to spread out leads only 2x
while($row = mysql_fetch_array($results))
{
	if($counter != 3)
	{
	//insert lead into column
	}
}
$counter++
}
else
{
//mysql query reset available bits to 0;
$counter = 0; //counter to spread out leads only 2x
while($row = mysql_fetch_array($results))
{
	if($counter != 3)
	{
	//insert lead into column
	}
}
$counter++
}

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.