Gossamer Forum
Home : Products : DBMan : Customization :

Display only the seven last records ?

Quote Reply
Display only the seven last records ?
Hello
What would be the link to display only the seven (or 5 or 10) last added records ?
Thanks a lot
Seth
Quote Reply
Re: Display only the seven last records ? In reply to
To make sure I understand you correctly, please look at the following web site:

www.anthrotech.com/cgibin/career/res/index.cgi?db=res&uid=default

I have this function working in this particular database. But before providing you codes, I want to make sure this is what you want.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Display only the seven last records ? In reply to
Not exactly
in your case, you display the records of the last seven days, what it means that if nobody had posted nothing till 10 days, the result would be nothing.
I would like to display the last seven records, even if the last one as added one month ago.
Another way to formulate my question would be "I there a way to display only a certain number of results ?".
Serge


------------------
Quote Reply
Re: Display only the seven last records ? In reply to
Seth

This will sort (&sb=0) by id, in descending order (&so=descend), max hits 7(&mh=7), wildcard in keyword search (&keyword=*),
Something like this link might work with a change in file location, db name...
<a href="http://www.your.com/db.cgi?db=default&uid=default&keyword=*&mh=7&sb=0&so=descend&view_records=View+Records">Last 7 Records Added</a>

Is this what you want?
Dave T


Quote Reply
Re: Display only the seven last records ? In reply to
Unfortunately not...
As in your solution, you still display all the records even if they are 200, but 7 by pages...
mh is a max hit by page but you still have "Page << 1 2 3 4 5 ... >>"
Seth
Quote Reply
Re: Display only the seven last records ? In reply to
seth, JPD wrote a mod awhile back, which she called whats_new_records, as opposed to whats_new_days as per Eliot's site. You can set up both if you wish.
Try:
http://www.gossamer-threads.com/...m12/HTML/000422.html
you don't have to have the dropdown, you could have a link instead.

hope this is helpefull
Quote Reply
Re: Display only the seven last records ? In reply to
lanerj,

The reference I gave (URL) is using this MOD, and it does not seem to be what Seth wants!

See ya.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Display only the seven last records ? In reply to
Well there is 2 mods in the thread we're talking about...
The whats_new_days mod, That I think you use, Eliot, and the whats_new_records mod, that would be perfect I think...
I tryed to include
Code:
sub query {
# --------------------------------------------------------
# First let's get a list of database fields we want to search on and
# store it in @search_fields

my ($i, $column, @search_fields, @search_gt_fields, @search_lt_fields, $maxhits, $numhits, $nh,
$field, @regexp, $line, @values, $key_match, @hits, @sortedhits, $next_url, $next_hit, $prev_hit,
$first, $last, $upper, $lower, $left, $right, $restricted);

local (%sortby);

if ($in{'whats_new_days'}) {
$in{'Date-gt'} = &get_date(time() - (($in{'whats_new_days'}+1) * 86400));
}

if ($in{'whats_new_records'}) {
open (DB, "<$db_file_name") or &cgierr("error in search.
unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>;
close DB;
$number_of_records = scalar(@lines);
$target_record = $lines[$number_of_records - ($in{'whats_new_records'} + 1)];
@data = &split_decode($target_record);
$in{"$db_key-gt"} = $data[$db_key_pos];
}

# First thing we do is find out what we are searching for. We build a list of fields
# we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
$i = 0; # thing in all fields. Make sure "match any" option is
$in{'ma'} = "on"; # on, otherwise this will almost always fail.
foreach $column (@db_cols) {
if (($db_sort{$column} eq 'date') or &date_to_unix($in{'keyword'})) { $i++; next; }
if ($i == $auth_user_field) { $i++; next; }
push (@search_fields, $i); # Search every column
$in{$column} = $in{'keyword'}; # Fill %in with keyword we are looking for.
$i++;
}
}
else { # Otherwise this is a regular search, and we only want records
$i = 0; # that match everything the user specified for.
foreach $column (@db_cols) {
if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or
return "Invalid date format: '$1'");
push (@search_gt_fields, $i); $in{"$column-gt"} = $1; $i++; next; }
if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or
return "Invalid date format: '$1'");
push (@search_lt_fields, $i); $in{"$column-lt"} = $1; $i++; next; }
if ($in{$column} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or
return "Invalid date format: '$in{$column}'");
push(@search_fields, $i); $i++; next; }
if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or
return "Invalid date format: '$in{$column}'");
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or
return "Invalid date format: '$in{$column}'");
push(@search_lt_fields, $i); }
$i++;
}
}
# If we don't have anything to search on, let's complain.

in my cgi and something happens Smile I mean what is displayed with the link http://www.epocboulevard.com/...mp;view_records.y=13 is the last records sorted by name, ie the records that begin with x, y, z.
I'd like to do the same but with the ID or the date, to have the lats added records.
It's always the last names (alphabetically) that appear.
???
Serge

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]

[This message has been edited by Seth (edited November 08, 1999).]
Quote Reply
Re: Display only the seven last records ? In reply to
  

[This message has been edited by Seth (edited November 08, 1999).]
Quote Reply
Re: Display only the seven last records ? In reply to
  

[This message has been edited by Seth (edited November 08, 1999).]
Quote Reply
Re: Display only the seven last records ? In reply to
Ooops ! Sorry for this ! I had errors when I was replying and I retryied ...


[This message has been edited by Seth (edited November 08, 1999).]
Quote Reply
Re: Display only the seven last records ? In reply to
Seth try taking out &sb=17 from your url, as you are sorthing by field 17, which may be your Name field. You can also delete whats_new_days from the url and sub_query if your not using them.
What do all the view_records mean in the url.

Bob