advancedfuture Posted November 18, 2008 Share Posted November 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 18, 2008 Share Posted November 18, 2008 Have a row in the table with the vendors saying what leads they have had? Quote Link to comment Share on other sites More sharing options...
advancedfuture Posted November 18, 2008 Author Share Posted November 18, 2008 yeah i could do that so it would only spread out the leads 2x, but im still kinda lost on how I would get it to say, okay these 2 got leads last time, now its time to give leads to this vendor Quote Link to comment Share on other sites More sharing options...
advancedfuture Posted November 18, 2008 Author Share Posted November 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 18, 2008 Share Posted November 18, 2008 Yeah it should work, although it means future reference of the leads they got is gone. Quote Link to comment Share on other sites More sharing options...
advancedfuture Posted November 18, 2008 Author Share Posted November 18, 2008 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++ } Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 18, 2008 Share Posted November 18, 2008 Looks ok, except the $counter is in the wrong place it should be inside the while loop. Quote Link to comment Share on other sites More sharing options...
advancedfuture Posted November 18, 2008 Author Share Posted November 18, 2008 thank you for your input =) I think I will be well on my way to getting this done now. I <3 this community Quote Link to comment 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.