techker Posted September 24, 2017 Share Posted September 24, 2017 Hey guys i have a script that runs with a CRON job every day while ($row2 = $result->fetch_assoc()){ $todays_date = date("Y-m-d"); $Dates=$row2['DateServices']; if ($todays_date < $Dates) { echo 'Subscription is ok'; echo "<br />\n"; echo $row2['name']; echo "<br />\n"; echo $todays_date ; }else{ echo 'Subscription is expired'; echo "<br />\n"; echo $row2['name']; echo "<br />\n"; echo $Dates ; } } So im having a hard time taking all the data (clients expired and inserting it in a Exired database (inserts email and date expired. one im ok ,but if there is 3 clients how can i take the info and insert one by one in the database? Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/ Share on other sites More sharing options...
requinix Posted September 24, 2017 Share Posted September 24, 2017 If you can do it with one then you can put the code into a loop, like the one you already have, and do it with many. I'm confused about what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551861 Share on other sites More sharing options...
techker Posted September 24, 2017 Author Share Posted September 24, 2017 its to insert in database all the clients expired. Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551863 Share on other sites More sharing options...
Barand Posted September 24, 2017 Share Posted September 24, 2017 You already have expired clients in your database and you know which ones they are. Why would you need to duplicate that information. It's a waste of time and space. Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551864 Share on other sites More sharing options...
techker Posted September 24, 2017 Author Share Posted September 24, 2017 true..how can i liste all the clients? i would like to send and email to the expired clients?i can't use mail function cause my server has bloqued it..smtp only? Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551865 Share on other sites More sharing options...
techker Posted September 24, 2017 Author Share Posted September 24, 2017 i can list with foreach ($row2 as &$value) { echo $value ; } im thinking i can send the information from there?but value gives me all the clients info Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551867 Share on other sites More sharing options...
Barand Posted September 24, 2017 Share Posted September 24, 2017 SELECT ... FROM ... WHERE DateServices < CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551868 Share on other sites More sharing options...
techker Posted September 24, 2017 Author Share Posted September 24, 2017 the selection of the clients is done like in my first post, i setled the insert in new database not doing since they are alreay there.. i would like to update the databse mark all expired clients with a flag. so i need to loop tru all the clients expired and update there profile with an expired flag that part im confused Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551869 Share on other sites More sharing options...
Barand Posted September 24, 2017 Share Posted September 24, 2017 The date field is already your expiry flag. If it's less than today, it's expired. You do insist on creating unnecessary work, don't you! Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551870 Share on other sites More sharing options...
techker Posted September 24, 2017 Author Share Posted September 24, 2017 true.. but how can i take that data and send it to an admin email saying all these clients are expirerd?i want to automate it.. Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551871 Share on other sites More sharing options...
Barand Posted September 24, 2017 Share Posted September 24, 2017 SELECT ... FROM ... WHERE DateServices < CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/305104-expired-clients/#findComment-1551872 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.