msql query
function NOW(){ return date('Y-m-d'); }
$rs_ctime = mysql_query("select `date` from `users` where `id` ='$user_id'") or die(mysql_error());
list($date) = mysql_fetch_row($rs_ctime);
if( (now() - $ctime) > 2days) {
////this is where i am stuck
i want to echo the result of the date each user registered until today.if the days are more than two days then i want to sent an email etc.
please help
$rs_ctime = mysql_query("select `date` from `users` where `id` ='$user_id'") or die(mysql_error());
list($date) = mysql_fetch_row($rs_ctime);
if( (now() - $ctime) > 2days) {
////this is where i am stuck
i want to echo the result of the date each user registered until today.if the days are more than two days then i want to sent an email etc.
please help
0
Comments
All you would have to do is set your query to something like "select <whatever> from <wherever> where `date` > <somedate> order by `date`"
Then you would only get users whose last date is older than the date you specify, which you can then use to build the rest of what you're looking at.
when user registers the date is recorded . i want to check if user has not activated link after two days so that an email will be automatically sent via cron
Then you can check and see if their activation link has been visited and send your e-mail accordingly. That reduces the length of your query, and reduces the complexity of your post-query processing.
so the qualifier can be
if(!$approved){
In pseudocode, since I don't want to bother taking the time to do your work for you
$day = date (d) - 2 //Gives us the number of the day minus 2. Will have to account for early in the month, etc, but you get the idea...
$date = date (Y-m-) + $day
$query = select <stuff> from <somewhere> where `regdate` < $date AND `approved` != 1 ORDER BY regdate
That query will return any user data where the user has been registered for more than 2 days but has not yet activated their account.
$result = mysql_query($query);
And then grab your rows in whatever method you feel is appropriate.
i am getting the above error for the line marked error
$day = date (d) - 2; //Gives us the number of the day minus 2. Will have to account for early in the month, etc, but you get the idea...
$date = date (Y-m-) + $day; ERROR
$query = select <user_name> from users where `date` < $date AND `approved` != 1 ORDER BY date
$result = mysql_query($query);
echo "($user_name)";
$query = select user_name from users where `date` < $date AND `approved` != 1 ORDER BY date
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
What Kwitko posted should work for what you're looking for, and will account for a first-of-the-month date.
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
'date' above is the field on my database when user registered. what is the unexpected T_CONSTANT