Gossamer Forum
Home : Products : DBMan : Discussions :

Re: [manic] Is this possible?

Quote Reply
Re: [manic] Is this possible? In reply to
A suggestion would be to add a field which automatically adds the date into the database when a record is added.

For the example of what I use i'm going to call the field in the example below I have the field defined as 'ArticleDate'

In your .cfg file add the field to hold the date (make sure you modify your current db file to add the extra field)

'ArticleDate' => [ 1,'date',12,15,0,&get_date(),''],

Then you can create a custom search form (see FAQ noted below if you need help with this)
As part of the custom search form you can modify the following code to show the dates as you choose.

Please note you may have to make changes to the line:

<OPTION VALUE="$months[$mon]/$day/$year">$daytext[$days]|;

to match the date format being used in your database. The example uses mm/dd/yyyy (06/17/2000) as the format of how the date is saved in the database.

print qq|
<TR><TD colspan=2><$font><B>Show by Article Date:</B></font> &nbsp; &nbsp; |;
my (@months) = qw!1 2 3 4 5 6 7 8 9 10 11 12!;
my (@number_of_days) = qw!2 3 4 8 15 32 64 192 366 732!;
# my (@number_of_days) = qw!2 3 4 8 15 32 64 192 366 732 1098 1464 1830 2196!;
$daytext[2] = "last day";
$daytext[3] = "last two days";
$daytext[4] = "last three days";
$daytext[8] = "last week";
$daytext[15] = "last two weeks";
$daytext[32] = "last month";
$daytext[64] = "last two months";
$daytext[192] = "last six months";
$daytext[366] = "last year";
$daytext[732] = "last two years";
# $daytext[1098] = "last three year";
# $daytext[1464] = "last four years";
# $daytext[1830] = "last five years";
# $daytext[2196] = "last six years";
# Note that each of the numbers is one day more than indicated by the text.

print qq|<SELECT NAME="ArticleDate-gt"><OPTION VALUE ="">---|;
foreach $days (@number_of_days) {
$time1 = time() - ($days * 86400);
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|<OPTION VALUE="$months[$mon]/$day/$year">$daytext[$days]|;
}
print "</SELECT>";
}

print qq|</TD></TR>

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Subject Author Views Date
Thread Is this possible? manic 3235 May 20, 2003, 2:44 AM
Thread Re: [manic] Is this possible?
LoisC 3135 May 20, 2003, 10:48 AM
Thread Re: [LoisC] Is this possible?
manic 3116 May 21, 2003, 2:50 AM
Post Re: [manic] Is this possible?
LoisC 3116 May 22, 2003, 12:28 AM