Gossamer Forum
Home : Products : DBMan : Customization :

Ask for adding the "Rate" into dbman-sql version

(Page 2 of 3)
> > > >
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Sorry about that...I will have to work on this later...I have an important report to work on for my job and I will most likely not be back to this forum until next week.

Adios!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

Well, good luck with work...I will see if I can figure out the problem when you are gone...Thanks for all your help!

Regards,

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

Welcome back! Just a little reminder for you to see if you can figure what was wrong with this code. Smile I've gotten no where in the last week! Thanks, Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Eliot-

Have you had a chance to look through the code yet? Thanks.

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Nope...I will try later this weekend.

I am maxed out on writing codes and modifications for DBMAN and LINKS.

After I finish this one with you...I am done.

Sorry, guys and gals.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hey Eliot,

Any progress on this? It still doesn't change the record, even though we get the success page. Thanks!

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Here is the solution that I have come up with:

1) Download LINKS and use the rate.cgi file.
2) In the rate.cgi file...change the following codes:

Code:
require "../links.cfg"; # Change this to full path to links.c
fg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";

With the following codes:

Code:
require "./default.cfg"; # Change this to full path to links.c
fg if you have problems.
require "./html.pl";

3) Rename the Teller field to Rating.

4) Then go through the rate.cgi file and check variables and make sure they match with fields in your html.pl sub-routines.

I should've thought of this before. And having a separate rating script is less intensive on servers, because of CPU and memory usage rates.

Start with what I have stated so far...and then when you run into difficulties, let us know.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

Thanks for responding, however I can't even get past the first step. I have tried the suggested code, substituted the full path, the URL, and numerous other variations, and I can never get the include to work (below). Permissions should be set up fine since I can get into db.cgi.
Code:
Error including libraries: Can't locate /html.pl in @INC (@INC contains: /usr/lib/perl5/i386-linux/5.00404 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at /default.cfg line 51.

Make sure they exist, permissions are set properly, and paths are set correctly.

Thanks,
Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Well, adding the following codes in the rate.cgi file:

Code:
$db_script_path = "/absolute/path/to/cgi-bin/dbman";

Then take out the require "html.pl"; in the rate.cgi file.

Regards,


------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Eliot-

Don't we also need to require db.cgi? If I leave it out, we won't be able to get_date, etc. Besides that, I have things going alright. What's the next step? Changing html_vote_form to point to rate_it or rate.cgi? Thanks.

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
That is the next step...which is to copy the sub-routines from the db.cgi file such as &get_date and all the other sub routine calls into rate.cgi.

YOU do NOT want to require db.cgi file. I am walking you through this ONE step at a time.

Wink

Keep going...

Smile

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Eliot-

Sorry I'm so jumpy - it's just that it's good to be finally getting somewhere Smile Okay, I have all the subs from db.cgi that I should need, and I also have the sub site_html_rate_form put in. I get the form when I try it out, and everything seems to be working ok. What's next? Smile

Thanks,
Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
* And you did create the $db_rate_path and define it in your default.cfg file, right?

If yes --->
if no <---- DO it.

* Are "id" files being created in the ratings directory that you defined in the $db_rate_path variable?

If yes ---->
If no <--- Then check the permissions of the ratings directory. Make sure it is 777 (rwxrwxrwx).

More to come after you answer these questions....

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

YES to putting in the ratings dir and defining it in default.cfg - and CHMOD 777 it. NO to IDs being built in the directory. Here's the code to my rate form in rate.cgi:
Code:
sub site_html_rate_form {
my (%rec) = @_;
&html_print_headers;
print qq|
<html><head><title>$html_title: Vote Record.</title></head>
<body link="#808080" vlink="#808080" alink="#808080" bgcolor="#FFFFFF">
<form action="http://mysite.com/cgi-bin/test/rate.cgi" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<p><font face="arial"><b>Vote</b></font><br>
<$font>Rate this Record:</font>
<select name="vote"> <option value="---"></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
|;
print qq|
<p><INPUT TYPE="SUBMIT" NAME="rate_it" VALUE="Vote"> <INPUT TYPE="RESET" VALUE="Reset Form"></p></form><P>|;
&html_footer;
print qq|</body></html>|;
}
All the votes vars have been changed to vote, and a "rating" field was added to default.cfg. After voting, I'm sent to my site's index page with broken pages within (it contains frames), which is beyond me since I don't have index.htm in rate.cgi, and my $auth_logoff isn't even defined as that! Hmmm... Smile

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Uh....sorry...You need to use the following sub-routines from LINKS for the rating script you are creating for DBMAN....

1) Delete all the rate sub-routines in the html.pl file.

2) Then add the following codes in the html.pl file:

Code:
sub site_html_rate_form {
# --------------------------------------------------------
# This routine determines how the rate form page will look like.
#
my %rec = @_;

&html_print_headers;
print qq~
<$dtd>
<html>

<head>
<title>$site_title: Rate a Resource</title>
<$css>
</head>

<$site_body>

<h1>$site_title: Rate a Resource</h1>

$site_menu

<form action="$build_rate_url" method="POST">
<input type=hidden name="$db_key" value="$in{$db_key}">
<p>Please rate the link <strong><a href="$rec{'URL'}">$rec{'Title'}</a></strong> between one and ten, with ten being tops.</p>
<div class="margin">
<p><select name=rate>
<option>---
<option>1
<option>2
<option>3
<option>4
<option>5
<option>6
<option>7
<option>8
<option>9
<option>10
</select>
<input type=submit value="Rate this Link">
</p>
</div>
</form>

$site_search
$site_footer

</body>
</html>
~;

}

sub site_html_rate_success {
# --------------------------------------------------------
# This routine determines how the add failure page will look like. You have
# access to the following variables:
#
# %in : the variables used to add the link, useful in confirming what was
# added.
#

&html_print_headers;
print qq~
<$dtd>
<html>

<head>
<title>$site_title: Resource Rated</title>
<$css>
</head>

<$site_body>

<h1>$site_title: Resource Rated</h1>

$site_menu

<p>Thank you for your vote.</p>

$site_search
$site_footer

</body>
</html>
~;
}

sub site_html_rate_failure {
# --------------------------------------------------------
# This routine determines how the rate failure page will look like. You have
# access to the following variables:
#
# $errormsg : A bulleted list of the problems.
#

my $errormsg = shift;

&html_print_headers;
print qq~
<$dtd>
<html>

<head>
<title>$site_title: Error Rating Resource.</title>
<$css>
</head>

<$site_body>

<h1>$site_title: Error Rating Resource</h1>

<p>Sorry, but we were unable to rate the resource for the following reason:
<p><strong class="error">
$errormsg
</strong></p>
<p>Please contact the site administrator if you have any questions.</p>

</body>
</html>
~;

}

You will have to edit these codes to work with the global variables (like $font, $html_title) in your html.pl file.

Okay...keep going...

Wink

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Okay Eliot - we're almost there! I finally have it building the IDs in the new folder. No changes still to default.db however. Should the extra field still be called "rating"? Thanks Wink

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Okay...here is the next step...which is going to be a bit complicated...I would not attempt it if it is late at night or early in the morning.

BTW: The earlier steps in this Mod is to collect the ID ratings, and also to reduce abusive ratings of your records. These earlier steps DO NOT ADD THE VALUE into the "rating" field in your database file.

Get it?

Please attempt the next steps with care....make complete backups of all your files, ESPECIALLY your database file...

To test this phase of the Mod, copy your default.db file.

This will also entail some testing and experimenting on your part, okay?

Are you ready....we here go....

1) Add the following variable definition in your default.cfg file:

Code:
$db_rating = 20;

Change 20 to the field number for your rating field.

2) Create a blank file and name it default.db.bak. Change the permission of this file to 666 (rw-rw-rw-). Put it in the same directory as your default.db file.

Now you will have to make a decision...do you want the Ratings to show up dynamically (which will slow down traffic) or do you want to add the Ratings via another script that will build ratings in your fields (not dynamic, but will not affect traffic, yet is more intensive on CPU and memory usage, since you will have to use Cron to make it pseudo-dynamic.)

Dynamic Ratings

1) Add the following sub-routine in your rate.cgi file:

Code:
sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.
#

# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
}
closedir HITS;

# Update the links database.
open (DB, "$db_file_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_file_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
}
print DBTMP &join_encode(&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_file_name.bak" > 0) {
if (! rename ("$db_file_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_file_name") or
&cgierr ("unable to open links database: $db_file_name. Reason: $!");
open (DB, "$db_file_name.bak") or
&cgierr ("unable to open temp links database: $db_file_name.bak. Reason: $!");
while ( ) { print DBTMP; }
close DB;
close DBTMP;
}
else { chmod 0666, $db_links_name; }
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}


# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");
}
}


2) To call this sub-routine, in your rate.cgi file, add the following codes:

Code:
&build_update_ratings

BEFORE the following codes:

Code:
&html_rate_success;

(or &site_html_rate_success; depending on what you called the success routine.)

Non-Dynamic via db.cgi script - Manual

1) Add the same sub-routine to your db.cgi file:

Code:
sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.
#

# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
}
closedir HITS;

# Update the links database.
open (DB, "$db_file_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_file_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
print "Content-type: text/html\n\n";
print "Database Ratings Updated."
}
print DBTMP &join_encode(&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_file_name.bak" > 0) {
if (! rename ("$db_file_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_file_name") or
&cgierr ("unable to open links database: $db_file_name. Reason: $!");
open (DB, "$db_file_name.bak") or
&cgierr ("unable to open temp links database: $db_file_name.bak. Reason: $!");
while ( ) { print DBTMP; }
close DB;
close DBTMP;
}
else { chmod 0666, $db_links_name; }
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}


# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");
}
}

2) Then add the following in the elsif section in the sub main routine in the db.cgi file:

Code:
elsif ($in{'build_ratings'}) { if ($per_admin) { &build_update_ratings; } else { &html_unauth; } }

3) Then add a link in the sub html_admin_display to this routine with the following codes:

Code:
<a href="$db_script_link_url&build_ratings=1">

4) Then to build new ratings you will have to access the Admin Console via the db.cgi and click on that link.

Non-Dynamic via db.cgi script - Automatic via Cron

1) Create a new script called buildrates.cgi. It should look like the following:

Code:
#!/usr/local/bin/perl
# This script builds ratings for DBMAN
# database.

# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "./default.cfg"; # Change this to full path to links.cfg if you have problems.
require "./html.pl";
};
if ($@) {
print "HTTP/1.0 200 OK\n";
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.
=============================================
# Additional Configurations
$db_script_path = "./";

sub main {
#-------------------------------------------
# Builds Ratings

# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
}
closedir HITS;

# Update the links database.
open (DB, "$db_file_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_file_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
}
print DBTMP &join_encode(&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_file_name.bak" > 0) {
if (! rename ("$db_file_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_file_name") or
&cgierr ("unable to open links database: $db_file_name. Reason: $!");
open (DB, "$db_file_name.bak") or
&cgierr ("unable to open temp links database: $db_file_name.bak. Reason: $!");
while ( ) { print DBTMP; }
close DB;
close DBTMP;
}
else { chmod 0666, $db_links_name; }
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}


# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");
}
}

sub array_to_hash {
# --------------------------------------------------------
# Converts an array to a hash using db_cols as the field names.
#
my ($hit, @array) = @_;
my ($i);
return map { $db_cols[$i] => $array[$hit * ($#db_cols+1) + $i++] } @_;
}

sub join_encode {
# --------------------------------------------------------
# Takes a hash (ususally from the form input) and builds one
# line to output into the database. It changes all occurrences
# of the database delimeter to '~~' and all newline chars to '``'.

my %hash = @_;
my ($tmp, $col, $output);

foreach $col (@db_cols) {
$tmp = $hash{$col};
$tmp =~ s/^\s+//g; # Trim leading blanks...
$tmp =~ s/\s+$//g; # Trim trailing blanks...
$tmp =~ s/\Q$db_delim\E/~~/og; # Change delimeter to ~~ symbol.
$tmp =~ s/\n/``/g; # Change newline to `` symbol.
$tmp =~ s/\r//g; # Remove Windows linefeed character.
$output .= $tmp . $db_delim; # Build Output.
}
chop $output; # remove extra delimeter.
$output .= "\n"; # add linefeed char.
return $output;
}

2) Then set-up a shell file and also edit your crontab, if you access to your shell account via telnet...Refer to the FAQ in the LINKS 2.0 section in the Resource Center for information on setting up Crontab. Use this stand alone script to automatically update ratings via Cron.

REALLY hope this helps.

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------













[This message has been edited by Eliot (edited February 16, 2000).]
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Wow, how do you do this so fast? Wink Yes, it is rather late here, so I'll give it a go some time tomorrow and get back to you. Many thanks!

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Credit goes to Carol for teaching me the ins and outs of DBMAN, Bobsie (and other LINKS users) for assisting me with LINKS, and my web guru who taught me Perl and HTML, and a little bit of Javascript.....

Wink

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

Changing those variables cause no ID to be created in the new directory, and the BAK file to be deleted. Yes, I'm working off a mirror image of my real database, and only put in 1 record in the db, so everything's fine to experiment with. Let me know if you figure out anything. Thanks Wink

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Hi Eliot,

I decided to go with the automatic version, an get an Internal Sever Error after voting. My default.db is then wiped out, and all fields show up in the default.db.bak file, along with "0.01" in the rating field no matter what number I rate it. Ideas? Thanks.

Cary
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
You did make backup of your files, I hope, and that you are using another file to test with, like test.db and test.db.bak, right? I did warn you about needing to experiment with this step!

Anyway...I will need to look at the codes I provided you and see what can be done. Try testing the other methods (manual and Cron) and see if that makes any difference.

I will be back later this week to look over the codes.

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Oops...notice one syntax error in the codes I gave you...

Replace the following codes:

Code:
$db_links_name

AND

Code:
$db_links_name.bak

with the following codes:

Code:
$db_file_name

and

Code:
$db_file_name.bak

About the Rating Number....It will not show 1-10, but percentages. I think what we may have to do is add another field called votes.
And then add the codes to increment the votes and give a percentage to the ratings based on number of votes...I deleted the codes from the LINKS codes that incremenets the $votes field and then passes that value into the $rating field and gives a percentage.

Let me look over the codes more closely...and I will provide edits later this week.

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------











Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Victory is ours!!! - I think Smile Okay, Eliot - The script is still deleting the BAK file, but I get the correct Ratings and Votes numbers now! I'm assuming the BAK file is a copy of the original in case it crashes? I think I confused you with my wording of why I was running buildrates.cgi - I didn't put it in the crontab for testing purposes, so I was just running it and "pretending" I was the crontab. I copied the code that you listed into the buildrate.cgi main sub since I'm using the crontab version and I'm on an UNIX server. MANY THANKS...YOU ARE THE MAN!!!!!!!!! (Can you feel my excitment?) Wink
Quote Reply
Re: Ask for adding the "Rate" into dbman-sql version In reply to
Good...Sorry it took so long...but with my new job and also ski season here, I do not have much time to spend in these forums.

Anyway...glad it is working...I would suggest cleaning up the instructions and use the ones that worked for you, and post this Mod in the Resource Center...I am through posting New Mods...But you can at least credit me for assisting you.

BUT before doing this, I would recommend testing this script with multiple records. So, copy your live default.db file and save it as test.db. Then try rating multiple records.

Also, experiment with the DYNAMIC METHOD and see if that works with the new codes provided.

Smile

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

> > > >