############################################################################################# ### ### ### N E W E S T R E C O R D S ### ### ### ############################################################################################# # # # # # This modification allows you to set up a link to search for the latest x number of records# # added to the database. You must either have a counter as the key field ($db_key_track = 1)# # or a field which automatically enters the date when a record is added. # # # # Updated 25 September 2006 to account for the short/long display. # # Thanks to delicia!!! # # # ############################################################################################# ############################################################################### #file: db.cgi # # sub main # # # # within the other "elsif" statements # # add the following # ############################################################################### elsif ($in{'new_records'}) { if ($per_view) { &html_new_records; } else { &html_unauth; } } ############################################################################### #file: html.pl # # add line # # sub html_footer # ############################################################################### print qq!| Newest Additions ! if ($per_view); ############################################################################### #file: html.pl # # new subroutine # # sub html_new_records # ############################################################################### sub html_new_records { # -------------------------------------------------------- $in{$db_key} = "*"; # Change the number below to the number of most recent records you want to display $in{'mh'} = 10; $in{'so'} = "descend"; # Change the number below to the *number* of your counter field or date field $in{'sb'} = 0; my ($status, @hits) = &query("view"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); &html_print_headers; print qq| $html_title: New Listings.
$html_title: New Listings

|; if ($status ne "ok") { print "<$font>There are no records in the database."; } else { print qq|<$font>These are the most recent additions to $html_title.|; # Go through each hit and convert the array to hash and send to # html_record for printing. for (0 .. $numhits - 1) { print "

"; &html_record (&array_to_hash($_, @hits)); } } print qq|

|; &html_footer; print qq|

|; } ########################################### #if you're using the short/long html $Create a new subroutine in html.pl -- sub html_record_new. Copy sub html_record and put it into the new subroutine. $ In the new subroutine, change #-------------------------------------------------------------------------------- $long_url = $ENV{'QUERY_STRING'}; $long_url =~ s/\&nh=\d+//; $long_url =~ s/\&mh=\d+//; $long_url = "$db_script_url?$long_url&nh=$record_number&mh=1"; #-------------------------------------------------------------------------------- #to #-------------------------------------------------------------------------------- $long_url = "$db_script_link_url&$db_key=$rec{$db_key}&view_records=1"; #-------------------------------------------------------------------------------- # Then, in sub html_new_records, change &html_record (&array_to_hash($_, @hits)); # to &html_record_new (&array_to_hash($_, @hits));