Jump to content

Recommended Posts

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?

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   ??????
?>

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.

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.