Hi All
I have another query on this. My boss has asked that I output a message
saying how many users need to be created before the one just submitted. Lets
say I have 8 users in the DB ready to be set up. 1 is on the 10th the rest
are on the 12th. If I insert a user on the 11th I want the output to say
"there is currently 1 user to be created before you" and so on depending on
the dates.
I am using an sql statement to get the number of rows (users) in the DB, but
how would I get it to distinguish between dates
$link = mysql_connect("localhost", "user", "pass");
mysql_select_db("db", $link);
$result = mysql_query("SELECT * FROM table", $link);
$num_rows = mysql_num_rows($result);
echo "There are currently \"$num_rows\" Users to be set up before you.\n";
?>
Thank you in advance
Mark M.
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Mark Mckee
Sent: 13 May 2007 20:32
To: [email protected]
Subject: RE: [php-list] after certain date do this....
That's certainly food for thought. I will break it down and test it over the
next couple of days. Hopefully you have it and I can get a working model to
show by the middle of the week. Thank you, I will let you know how it works
out
From: [email protected] <mailto:php-list%40yahoogroups.com>
[mailto:[email protected] <mailto:php-list%40yahoogroups.com> ] On
Behalf
Of Pete
Sent: 13 May 2007 20:23
To: [email protected] <mailto:php-list%40yahoogroups.com>
Subject: Re: [php-list] after certain date do this....
In message <[EMAIL PROTECTED]>, Mark Mckee
<[EMAIL PROTECTED] <mailto:lists%40soddengecko.com>
<mailto:lists%40soddengecko.com> > writes
>I have not got a piece of code as I cannot seem to get my head around it.
>What I do have is what I am using to extract the data from the database.
>
>
>
>When the date is inserted into the database it is formatted like this
>14-05-2007 and is displayed the same way.
Ah - what sort of database is it? It looks like you might be using
MySQL, in which case, you don't seem to be using a date field. Am I
correct?
I would do it in two steps - the report, and the emails. There isn't
really a connection between the two, other than the table is the same
one.
If the field were a MySQL date field, then it would be:
>$sql="SELECT * FROM user_info ORDER BY Start_Date";
Try to name the fields that you are selecting - you will no doubt change
them later, when the boss changes their mind, and you should never
return more fields than you need.
$sql="SELECT Title, First_Name, Last_Name, Department_Name, DATE_FORMAT(
Start_Date, '%d-%m-%Y') AS startdate, DATE_ADD(Start_Date, INTERVAL 5
DAY)>NOW() AS overdue
FROM user_info ORDER BY start_date";
(note that you will be echoing "startdate", not "Start_Date")
>echo "
><tr bgcolor='#F0F5FE'>
>
echo ($rows['overdue'])?"<tr bgcolor='##FEF0F5'>":"<tr
bgcolor='F0F5FE'>";
Then I would write a second and third script, with
$sql="SELECT Title, First_Name, Last_Name, Department_Name, Start_Date
FROM user_info WHERE Start_Date > NOW() ORDER BY start_date";
and
$sql="SELECT Title, First_Name, Last_Name, Department_Name, Start_Date
FROM user_info WHERE DATE_ADD(Start_Date, INTERVAL 5 DAY)>NOW() ORDER BY
start_date";
and send emails for every record returned. These would usefully be run
with a cron job.
All untested... <G>
--
Pete Clark
Sunny Andalucia
http://www.hotcosta.com/comm_1.htm
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]