lice200 Posted June 12, 2006 Share Posted June 12, 2006 Hey, I wrote a script to check the date of a link, find how old it is, then if it is older then the said max date, delete it. But I cannot figure how to have it delete it... on its own...[code]<?php $query=("SELECT * FROM archive ORDER BY link_id DESC");$result=mysql_query($query);$row = mysql_fetch_row($result);$link_id = $row[0];mysql_close();$curmonth = date('m-d-Y') + 0; //Find out the current month$monthchange = $link_date + 0; //Find out the month of the link$month = $curmonth - $monthchange; //Find the month offsetif($month < 2){ //Do nothing if link is less then 2 months old } if($month == 2){ //Do nothing if link is 2 months old }if($month > 2){ //Start deletion process if link is older then 2 months//Here is where i tell it to auto-delete the link..}?>[/code]I don't know what to put to make it auto-delete it. I have a delete script set up to run of link_id. Can you help me please? Link to comment https://forums.phpfreaks.com/topic/11800-auto-delete-script/ Share on other sites More sharing options...
poirot Posted June 12, 2006 Share Posted June 12, 2006 I can't see how you are retrieving $link_date, but if it is stored as a UNIX timestamp, you can work that out with:[code]$limit = time() - 5184000;if ($link_date < $limit) { // too old...} else { // do something else...}[/code]5184000 = 60 days = 60 * 60 * 24 * 30Now, 60 days isn't exactly 2 months but it's pretty close to it. If you want a more exact calculation, it's a bit more of work, but I don't like it [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Link to comment https://forums.phpfreaks.com/topic/11800-auto-delete-script/#findComment-44714 Share on other sites More sharing options...
lice200 Posted June 12, 2006 Author Share Posted June 12, 2006 When you add + 0 to the date in $curmonth it will show only the month. now i can take the current month which is 6, take the month of the link which is 3, find out the difference which is 3. Now that i know the link is three months old. I need to have it delete it. My problem is not with how I have the date setup, that is fine. My problem is i dont know how to make it auto-delete it. Like i said before, i have a delete script that is setup to run off $link_id. So if i tell it to delete link_id=17 it will delete the 17th link...So again my question is. What can I use to make it delete the link when it hits age? Link to comment https://forums.phpfreaks.com/topic/11800-auto-delete-script/#findComment-44733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.