Richard Kurth wrote:
What I am trying to is get all the days from a table where email
campaign = number. and then look at the last day that was sent and find
it in the list and get the next day that follows that day. At this point
the script below is not working. So if you have any Ideas that would be
a better way of doing this please let me know.
$query = "SELECT day FROM emailcampaign where campaign_id =
'$emailcampaign' AND member_id = '$members_id'";
$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i < mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1 < count($Campaign_array)){ echo $Campaign_array[$k + 1]; }
Ok, so just to recap (because I'm very confused now, even more after the
many tries on the list since):
You have table in your database called 'emailcampaign'. This table has a
column called 'day'.
Now, your table holds 1 row per "campaign" and the 'day' column
signifies when the last mail has been sent.
-- am I correct on this so far ? --
Next, you have an array which contains a FIXED collection of days on
which an email should be sent, which looks like so:
$days_to_send_email_on = array('0','1','3','5','8','15','25');
-- am I correct on this so far [2] ? --
You know the 'day' the last mail was sent, and you wish to check your
FIXED array to find out when the next email should be sent.
-- am I correct on this so far [3] ? --
If so, then there are a few things I'm wondering:
1. How did you come up with that fixed array? Is it the result of some
kind of calculation?
1.1 If so, it'd be easier to solve it the mathematical way.
1.2 If #1 is a "random" result (ie. user-input, or different), then
how about storing it in a table and doing:
SELECT day WHERE day > $last_day_it_was_sent_on ORDER BY day ASC LIMIT 1
2. Actually, that's all I'm wondering :)
- Tul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php