Gossamer Forum
Home : Products : DBMan : Discussions :

accessing data from previous record

Quote Reply
accessing data from previous record
I need to access the data from 1, 2, 3, 4 records previous to the current record. This is what I have come up with so far.

my $current=$rec{'$keyfield'}-1;
my %rec2 = &get_record('$current');

I am not very well versed in perl, but I think this should work... any suggestions?Crazy
Quote Reply
Re: [don_son] accessing data from previous record In reply to
Are you wanting to create a report to to perform calculations on the fields?

If so, I'm sure if you visit the FAQ noted below and look under the sections "Calculate" and "Viewing" you will find some ideas and possible solutions.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] accessing data from previous record In reply to
LoisC,

Thank You. Your DBman Help FAQ is an awesome resource. I found a post that is pertinent to my dilemna (http://webmagic.hypermart.net/...us&nh=4&mh=1), however it does not seem to work for me. Maybe I am doing something wrong?

This is the code it recommends...

Quote:


$next = $rec{$db_key} + 1;
$prev = $rec{$db_key} - 1;


I would like to apply the value to a new hash called %rec2 by this;

%rec2=&get_record($next);

Any Help?
Quote Reply
Re: [don_son] accessing data from previous record In reply to
I'm afraid posting the url to the FAQ doesn't work as you have to be logged in to view the database. Also there is no reference to the record ID or original thread.

Perhaps you can locate this reference again and then locate the original thread (noted within the record) and then reference that directly. Sometimes the actual thread reference differs in the FAQ, so by providing the title, etc. a search can be done to locate the original thread here in the forum.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] accessing data from previous record In reply to
Sorry about that, Here is the entire thread. I don't see how you get to the original thread? I know this isn't what I need but the part where calculations are done on the %rec. It still isn't working for me... any comments anyone?

Quote:


Category(s): Navigate 749 25-Oct-2001 Last Modified: 25-Oct-2001 Question about previous/next records

Is it possible to get from the previous/next records code the actual $rec{$db_key} of the associated record? I would like to pull a field off both the previous and next records to display on the current record, e.g.

RECORD X
Field N of Record X-1
Field N of Record X+1

If I use $nh, it get the field from the record at the abosulte position in the database, as opposed to the relative position in the search results.

Response:

Define the following two variables in the sub_html_record_long routine:

$next = $rec{$db_key} + 1;
$prev = $rec{$db_key} - 1;

Then add the following URLs to your sub html_record_long routine after the print qq|
code.

< A HREF=''$db_script_link_url&ww=on&$db_key=$next&view_records=1'' >Next Record< /A >
< A HREF=''$db_script_link_url&ww=on&$db_key=$prev&view_records=1'' >Previous Record< /A >

(remove spaces in url links .. added for FAQ display)