Salutations one and all! I'm wondering if someone can give me a hand with this little task that I have. I'm almost positive I'm on the right track here, but for some reason its not working.
Basically what I want to do is in the html_record_long routine (in the Short/Long html.pl) have it display other records that "relate" to it. This doesn't entail the relational mod, in that I actually want it to display records from the same .db file. SO, what I have done is set it up so that when the user is entering a record, he/she gets a drop down menu of all the other titles in the database (using the build_select_field_from_db sub). When you enter a record, you can choose if it relates to another record by choosing it from the dropdown. This gets saved in a field called "SubSection." Pretty nifty, eh?
So, the next step is to have the database, when displaying record_long, check the database to see if there are other records in there that have the current records $rec{'Title'} in the SubSection field. I have tried doing this by, basically, jury-rigging the "Display Headlines on Home Page" mod from the Unofficial FAQ. The code I'm putting in html_record_long looks like this:
open (DB, "<$db_file_name") or &cgierr("error. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
my @lines = <DB>;
close DB;
my $LASTX = 20;
for ($i=$#lines; $i>=($#lines - $LASTX); $i--) {
chomp $lines[$i];
@data = split(/\|/,$lines[$i]);
next unless ($data[4] eq $rec{'Title'});
$latest .= qq|$data[1]<BR>|;
}
print $latest;
Now, this works little mod works fine as long as I don't include the
next unless ($data[4] eq $rec{'Title'});
But then it, of course, just returns every record in the database... Not just the ones related to the current record. When I leave that line in, the database doesn't return anything.
So, any thoughts would be heavily heavily heavily appreciated. You can check out my html.pl file and .cfg file here and here (respectively).
The code that is supposed to be calling the headlines starts around line 316.
Many thanks in advance, all! Cheers!
Basically what I want to do is in the html_record_long routine (in the Short/Long html.pl) have it display other records that "relate" to it. This doesn't entail the relational mod, in that I actually want it to display records from the same .db file. SO, what I have done is set it up so that when the user is entering a record, he/she gets a drop down menu of all the other titles in the database (using the build_select_field_from_db sub). When you enter a record, you can choose if it relates to another record by choosing it from the dropdown. This gets saved in a field called "SubSection." Pretty nifty, eh?
So, the next step is to have the database, when displaying record_long, check the database to see if there are other records in there that have the current records $rec{'Title'} in the SubSection field. I have tried doing this by, basically, jury-rigging the "Display Headlines on Home Page" mod from the Unofficial FAQ. The code I'm putting in html_record_long looks like this:
Code:
open (DB, "<$db_file_name") or &cgierr("error. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
my @lines = <DB>;
close DB;
my $LASTX = 20;
for ($i=$#lines; $i>=($#lines - $LASTX); $i--) {
chomp $lines[$i];
@data = split(/\|/,$lines[$i]);
next unless ($data[4] eq $rec{'Title'});
$latest .= qq|$data[1]<BR>|;
}
print $latest;
Now, this works little mod works fine as long as I don't include the
next unless ($data[4] eq $rec{'Title'});
But then it, of course, just returns every record in the database... Not just the ones related to the current record. When I leave that line in, the database doesn't return anything.
So, any thoughts would be heavily heavily heavily appreciated. You can check out my html.pl file and .cfg file here and here (respectively).
The code that is supposed to be calling the headlines starts around line 316.
Many thanks in advance, all! Cheers!

