ecabrera Posted March 16, 2015 Share Posted March 16, 2015 i have landing page and i want to send each lead that i get from the landing page to a email. here is the problem i want something like this lead 1 -> email 1 lead 2 -> email 2 lead 3 -> email 1 lead 4 -> email 2 lead 5 -> email 1 lead 6 -> email 2 here is my code if $last is 1 than that was the last person that got a lead so if the $last is 0 than i want them to get the new lead and update the $last = 0 to 1 and the $last 1 to 0 my database looks like this id| name |email | last 1 | josh |josh@mydomain.com |1 2 | alex |alex@mydomain.com |0 any idea how to work this out require "db.php"; $get = "SELECT * FROM `users`"; $getquery = mysqli_query($db,$get); while($rows = mysqli_fetch_assoc($getquery)){ $id = $rows['id']; $dbemail = $rows['email']; $last = $rows['last']; if($last == 0){ //echo "Sent to: $dbemail <br>"; //emails whill go here $newlast = "1"; $u = "UPDATE `users` SET `last`='$newlast' WHERE `last` = '0'"; $uquery = mysqli_query($db,$u); } if($last == 1){ $newlast1 = "0"; $u1 = "UPDATE `users` SET `last`='$newlast1' WHERE `last` = '1'"; $uquery1 = mysqli_query($db,$u1); } } Quote Link to comment https://forums.phpfreaks.com/topic/295292-update-user/ Share on other sites More sharing options...
rwhite35 Posted March 16, 2015 Share Posted March 16, 2015 (edited) What happens if you have to add two or three more users? You might want to reconsider your database schema. One table for your users, one table for the leads rotation. In that way you separate the data into manageable concepts. Then when you lookup who had the last lead, you could prioritize a rotation with some simple logic. If 5 was the last to get a lead, then start the rotation from the top. Good luck. Edited March 16, 2015 by rwhite35 Quote Link to comment https://forums.phpfreaks.com/topic/295292-update-user/#findComment-1508244 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.