Gossamer Forum
Home : Products : DBMan : Customization :

Display 1 field of last record in search result

Quote Reply
Display 1 field of last record in search result
Hi,

Can anybody tell me how to do this:

I want to display the first field (named 'Kop') of the last added record (highest ID) on top of the search result page.

Help is very much appreciated, kind regards.

SeP

Quote Reply
Re: Display 1 field of last record in search result In reply to
Code:

open (ID, "<$db_id_file_name") or &cgierr("error. unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) { flock(ID, 1); }
$key_value = <ID>;
close ID;

my (%last) = &get_record($key_value);

print "$last{'Kop'}";
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Display 1 field of last record in search result In reply to
Thanks, that works great. You don't want to know what I was trying. I already stumbled across the next problem, do you know how I can combine two text field and a pull down menu in an external HTML file in one field (a date)? To search the database for a specific date?

Quote Reply
Re: Display 1 field of last record in search result In reply to
Well, there are several ways you could go about doing what you wanted to do. This just seemed like the easiest one.

Regarding your new question -- I don't think I understand what you want to do. Can you be a little more specific?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Display 1 field of last record in search result In reply to
Goodmorning! (-:

Well, what I want to do is a date range search in a news database. But because my site is in Dutch, I want to do the search from an external HTML file with three inputs: a textfield for the day, a pull down menu with the months and a textfield with the year. But the date field in my database is only one field, so i wondered how I can combine these three values to one date value.

Kind regards, SeP

Quote Reply
Re: Display 1 field of last record in search result In reply to
Create fields on your .html file named Day, Month, and Year. (Actually, you can name them anything you like. But those are the names I'm going to be using in the code below.) Also I'm assuming the name of your database field is Date.

In db.cgi, sub query, after

local (%sortby);

add

Code:

if ($in{'Day'} && $in{'Month'} && $in{'Year'}) {
$in{'Date-gt'} = "$in{'Day'}-$in{'Month'}-$in{'Year'}";
}
Notice that all three fields must be filled in. Also, there must be 4 digits in the year field.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Displaying 1 field of last record on home page In reply to
I have been trying to add a line to html_home that says: "Welcome to our newest registered member: (insert data from the last record entered, field pos#1, called 'claname'). I have searched and tried a number of different approaches, but nothing seems to work. This looks to be very close to what I need to do, but really lack the perl skills to modify it properly to make it work on my page. Any help would be greatly appreciated! Oh, the members database can be reached from the "members" link is http://www.snakegod.org (a lighthearted bunch of online gamers ... NO other significance to that name:)