defeated Posted March 14, 2008 Share Posted March 14, 2008 Hi, I have a form where one of the selects is number of days before data expires. Problem is I have no idea what the syntax should be to set the expiry date (expire_date column) as now() plus x days where x is the inputted number of days selected in the form. ??? It's probably easy but not to me right now.... can't find how to do it anywhere. Further more I want to be able to update the expiry date if the data is expired by another x days without showing the whole form again. ie, have a column in the outputted display of all data (expired and current) in my cms that allows me to click on it and a select of days is shown that where I can click on the day number (1-60) and it automatically updates the expiry colm to x days hence. With me? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted March 14, 2008 Share Posted March 14, 2008 <?php $number = 3; $today = strtotime("NOW"); $then = strtotime("+ $number Day", $today); //adds the number of days onto now $date = date(date("j-M-Y ", $then); echo $date; //prints out 17-MAR-2008 ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted March 14, 2008 Share Posted March 14, 2008 Not really sure what you want... an UPDATE statement? Assuming you have the expiry_date field, you can use " + INTERVAL x DAY" to push it push. Quote Link to comment Share on other sites More sharing options...
defeated Posted March 14, 2008 Author Share Posted March 14, 2008 Hey Paul, I think that's close to what I want to do. Only problem is the date format... want to keep it the same way as mysql eg 2008-03-17 and only change the format if I'm echoing it out to a html page. Does this work or am I way off? <?php $number = 3; $today = strtotime("NOW"); $then = strtotime("+ $number Day", $today); //adds the number of days onto now $date = date(date("Y-M-D ", $then); echo $date; //prints out 2008-03-17 ?????? ?> Quote Link to comment Share on other sites More sharing options...
defeated Posted March 14, 2008 Author Share Posted March 14, 2008 Fenway, What I'm looking for is two things. The expiry date column is called expiry_date First: Insert.......... "values(now() + INTERVAL x DAY)" where x=$_REQUEST['number of days to expiry from form'] ; It's a syntax problem. I don't know what to put where. Second: Update.......... $row[expiry_date]+ INTERVAL x DAY I will have an "<a href=update.php?id=<?php echo $rowid ; ?>>update</a>"on my cms page. Ideally I want to have it so that just clicking the anchor displays a dropdown list of select options (days 1-60) that can be chosen without leaving the page and selecting the number from the list activates the anchor and also passes the selected number of days along with the row id? I'd settle just having the select in update.php?id=<?php echo $rowid ; ?> where the submit would go to update1.php?id=<?php echo $rowid ; ?> and then I need the correct syntax for the line "update..... $row[expiry_date etc. Crap I'm confusing myself now. Quote Link to comment Share on other sites More sharing options...
defeated Posted March 14, 2008 Author Share Posted March 14, 2008 Fenway, Further to last post. I'm just wondering if it's possible. I reckon the second question probably requires java about which I know even less than I know about php and mysql (yes that's possible). I have an idea in my head of how i'd like it to work in a user friendly if not programmer friendly fashion but I'm open to suggestions. Ian. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 15, 2008 Share Posted March 15, 2008 I'm very confused at to what you want. EDIT: Thread continues here. Quote Link to comment 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.