Gossamer Forum
Home : Products : DBMan : Installation :

date format and sorting

Quote Reply
date format and sorting
 
I f I defin e a field as a date, can i sort on it ? if so, what date format?
if not, do I have to define each field separately and put them together
eg yyyy+mm+dd
OR
can I do al sort on sequential fields eg yyyy then mm then dd?
Quote Reply
Re: [pdc124] date format and sorting In reply to
A simple way of creating a default sort field and sort order would be to add the following to your .cfg file:

$sort_field ='3';
$sortorder = 'ascend'; OR: $sortorder = "descend';

Then just use the variable in your links, form, etc. This makes it very easy to change if your sort order, and you can easily use the same db.cgi files for various databases.
Just change the 3 to match the field you want to sort by.

Examples:

In your footer you could use:

<A HREF="$db_script_link_url&view_records=1&$db_key=*&sb=$sort_field&so=$sortorder>View All Entries</A> ! if ($per_view);


In various forms including sub html_view_search you could add extra hidden fields:

<input type="hidden" name="sb" value="$sort_field">
<input type="hidden" name="so" value="$sortorder">

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] date format and sorting In reply to
but if i want to sort on a date field, what format does the date field have to be in?
Quote Reply
Re: [pdc1234] date format and sorting In reply to
I'm sure whatever default date format you have set will work.

If you use the default date format of DBMan in your .cfg file you would just define the field as:

Date => [4, 'date',12,15,1,&get_date,''],

Changing the field number to match yours. If you have changed the date format, then you will have to modify subs within the db.cgi file.

Unoffical DBMan FAQ

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