Gossamer Forum
Home : Products : DBMan : Installation :

Show the number of records to add...

Quote Reply
Show the number of records to add...
Hi,
JPD helps me with the mod of giving a user a max of records to add. I like to show the number of records, a registered user can add, the moment, he has the adding screen. I think it's possible, the info is already in the http://www.gossamer-threads.com/scripts/forum/resources/Forum5/HTML/000827.html, but I don't know, how to change it, so the info appears in the screen when a user goes to add a record.
Quote Reply
Re: Show the number of records to add... In reply to
You can use part of the same code that you used in validating the record.

Add this to the beginning of html_add_form:
Code:
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file:
$db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
$count = 0;
LINE: while (<DB> ) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_;
chomp ($line);
@data = &split_decode($line);
if ($data[$auth_user_field] eq $db_userid) {
++$count;
}
}
close DB;
$left = $db_maximum_records - $count;

Then, before the line that starts with &html_record_form, add

print qq|You currently have $count records in the database. You may add $left more records.|;

I'm sure by now you understand about putting things within a print qq| statement, so what you actually add to your file may need to be a little different.


------------------
JPD