Jump to content

[SOLVED] Is there a way to do this or am I asking too much


Recommended Posts

What I would like to do is add an expire date that is 30 days out based on the Time_submitted value but I have no clue where to start can anyone help?

 

<?php

include("k_falls_dbinfo2.inc.php");

mysql_connect(mysql,$username,$password);

mysql_select_db($database) or die( "Unable to select database");

 

$query = "INSERT INTO test (name, time_submitted) VALUES ('$name', now())";

mysql_query($query);

mysql_free_result( $result );

mysql_close();

echo "All Done.";

?>

???

 

now() of mysql will do it flawlessly..

all you need to do is insert the current date then query it something like

 

sample your field for the date is

my_date

 

 

all you need is a query that says

select * from table where DATEDIFF('now()','my_date') <=30; // returns all dates that is less than 30 days

does that help?

 

 

I used now as expiration date you can also put what ever youwant

 

select (DATEDIFF('now()','my_date') -30) as days expire  from table where DATEDIFF('now()','my_date') >30;
//returns the number of days of expiration eg. if 31 1 day expired...
select DATEDIFF('now()','my_date') as days expire  from table where DATEDIFF('now()','my_date') >30;
// returns the total days of exiration eg 30 31, 32 etcc

 

maybe this?

you can add fields or tables.. that will have

expiration range and maybe expiration id

 

so to set it up you will have something like this

 

 

exId  Range

1        10

2        20

3        30

//ect...

 

select DATEDIFF('now()','my_date')as days expire  from table where DATEDIFF('now()','my_date') >Range and exId = 'youridhere';

 

does that makes sense?

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.