Jump to content

Alerting depending on selection


greens85

Recommended Posts

Hi all,

 

I am trying to produce a script that will send out an email but the user can basically choose how often they get this email... I want to give them the option of daily, weekly and monthly. I have the logic down on paper and in plain English it seems to make sense but I am having a hard time converting this to code:

 

My logic is:

 

1. find out how often they want to get the email (we will call this frequency, as thats what my database field is called)

 

2. drag out last updated timestamp (this is called last_updated and is a unix timestamp)

 

3. some form of compare i.e. if frequency is weekly and $today is 7 days after last reminded alert them

 

as I say this makes sense in plain English but I'm having a hard time converting it... this is what I have come up with so far:

<?php
// Connect
include("../connect.php");

$query = "SELECT * FROM resumes_bak WHERE jobseekerid = '2610'";
	$result = mysql_query($query) or die (mysql_error());
		while ($row = mysql_fetch_array($result)) {


			$current_timestamp = time();
			echo "Current Timestamp: ".$current_timestamp;
			echo "<br /><br />";

			$frequency = $row['frequency'];
			echo "Frequency is: ".$frequency;
			echo "<br /><br />";

			$lastReminded = $row['last_reminded'];
			echo "Last reminded: ".$lastReminded;
			echo "<br /><br />";

			$daily = strtotime('+1 day', $lastReminded);
			echo "One day forward: ".$daily;
			echo "<br />";
			$weekly = strtotime('+1 week', $lastReminded);
			echo "One week forward: ".$weekly;
			echo "<br />";
			$monthly = strtotime('+1 month', $lastReminded);
			echo "One month forward: ".$monthly;
			echo "<br /><br />";

			if($frequency = 'daily' && /* I THINK I NEED ADDITIONAL CLAUSES IN HERE TO DO THE COMPARISON */ ) {

				echo "I am daily";

			} elseif ($frequency = 'weekly') {

				echo "I am weekly";

			} else {

				echo "I am monthly";

			}

		}
?>

 

Can anybody help me on my way here, I seem to have hit a wall!

 

Many thanks,

 

Greens85

 

Link to comment
Share on other sites

Hi all,

 

Think I might have made some progress with this with the following if statement:

 

if($daily == $current_timestamp) {

					echo "I need to be alerted";

				} else {

					echo "I don't need to be alerted";

				}

 

Hard to test when I'm working with days in advance though :)

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.