Jump to content

update user


ecabrera

Recommended Posts

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);

}

}
Link to comment
Share on other sites

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 by rwhite35
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.