Hi Carol and Everyone,
I am back working on my Classified Ads project. I am experiencing difficulties inserting the following code into the browse_cat sub-routine that I have
written:
BEFORE
if ($db_cols[$i] eq "Category") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No Category field defined");
}
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
++$count{$fields[$fieldnum]};
}
close DB;
I also tried the following variations with that code.
Examples:
AND
AND
AND
None of this works.
I get syntax errors with everything I try.
ALSO, I need to find a way to modify the sub num_records sub-routine in the db.cgi (index.cgi) file. I have the following codes in place:
# --------------------------------------------------------
# Displays the number of records
($per_admin) or ($in{'Validate'} = "Yes");
my $count = 0;
open (DB, "<$db_file_name") or &cgierr("error in num_records. unable to open database:
$db_file_name.\nReason: $!");
LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$count++;
}
}
print $count;
}
The bolded line is what I added thinking that it would only show the number of validated records for general users, and the total number of records in the database for administrators. Yet, it shows the same number for both. Hmm...
If you have time, I would really like your assistance or anyone else who knows how I can modify the category listing to only include "validated" records.
TIA.
Regards,
------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
[This message has been edited by Eliot (edited August 14, 1999).]
[This message has been edited by Eliot (edited August 14, 1999).]
[This message has been edited by Eliot (edited August 14, 1999).]
I am back working on my Classified Ads project. I am experiencing difficulties inserting the following code into the browse_cat sub-routine that I have
written:
Code:
unless ($data[3] eq "Yes")BEFORE
Code:
for ($i = 0; $i <= $#db_cols; $i++) { if ($db_cols[$i] eq "Category") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No Category field defined");
}
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
++$count{$fields[$fieldnum]};
}
close DB;
I also tried the following variations with that code.
Examples:
Code:
unless ("Category" eq 'Yes')AND
Code:
unless ($rec{'Category'} eq "Yes")AND
Code:
unless ($rec{'Validate'} eq "Yes")AND
Code:
unless ("Validate" eq 'Yes')None of this works.
I get syntax errors with everything I try.
ALSO, I need to find a way to modify the sub num_records sub-routine in the db.cgi (index.cgi) file. I have the following codes in place:
Code:
sub num_records { # --------------------------------------------------------
# Displays the number of records
($per_admin) or ($in{'Validate'} = "Yes");
my $count = 0;
open (DB, "<$db_file_name") or &cgierr("error in num_records. unable to open database:
$db_file_name.\nReason: $!");
LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$count++;
}
}
print $count;
}
The bolded line is what I added thinking that it would only show the number of validated records for general users, and the total number of records in the database for administrators. Yet, it shows the same number for both. Hmm...
If you have time, I would really like your assistance or anyone else who knows how I can modify the category listing to only include "validated" records.
TIA.
Regards,
------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
[This message has been edited by Eliot (edited August 14, 1999).]
[This message has been edited by Eliot (edited August 14, 1999).]
[This message has been edited by Eliot (edited August 14, 1999).]