Gossamer Forum
Home : Products : DBMan : Discussions :

Is this possible?

Quote Reply
Is this possible?
I run a unsigned band database and I want to have a search field that specifys when the band was added to the database.

At the moment i have a select box (called time_period) with "Last 10 weeks" and "From the beginning" and at the moment when i get a new band entry i select "Last 10 weeks", and each week i change the old entrys (that are now 11 weeks old) to "From the beginning". Is there anyway i can make the database do this automatically?

I thought of adding a data field, but i'm not sure how that would work.

Any help would be appreciated.

Thanks.
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/
Quote Reply
Re: [LoisC] Is this possible? In reply to
Thanks for the reply and code.



Just one question where do i put <OPTION VALUE="$months[$mon]/$day/$year">$daytext[$days]|; ?

I take it, it goes in the html.pl file but where?



Thanks again.Smile
Quote Reply
Re: [manic] Is this possible? In reply to
The whole section of coding would go within the sub for your custom search form within your html.pl file.

There are examples and instructions for how to add the custom form to your footer, and also how to direct searches to this form rather than the default keyword search form in the FAQ noted below under the section for "Searching".

You would can even have both search forms available to your users. But you will need to create a new sub for your search form and include the fields you want to search on, and then also the coding above to search by time frames.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/