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   |[email protected] |1

2 | alex   |[email protected] |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
https://forums.phpfreaks.com/topic/295292-update-user/
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.

Link to comment
https://forums.phpfreaks.com/topic/295292-update-user/#findComment-1508244
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.