FX Do Rate Single  (by Felice Di Stefano)
(ASP Js, ASP Vbs, PHP MySQL, PHP ADODB)

This server behavior will add the necessary code to rate a single item using an input like a listmenu or radio group. For instance you may apply it on details page (see demo 3) or you may create an array of items each having its own rating form (see demo 4).

Preparing the page

You may use any of the tables of your database which is suitable for this task, you will need to add two columns, one to record the score as float and one to count voters as integer, you can name these as you wish and set a default value of 0. It will be required the creation of a table with a single column Varchar 50 to collect all the IPs together the item identifier to avoid that users may vote more than one time. Remember that for each poll relative to a table or group of items you must have a dedicated IPs table, just name it as you like.
In case of a single rating for a single item like in a detail page create a recordsets to retrieve the required data to display like item name or description and score and voters if you want to display the actual rate, and also the relative unique identifier like an id and filter it by a variable passed to select the specific record.
In case of an array of single items each having its own rating form do the same as above but do not filter the recordset.
At this point insert a form on the page and inside display the candidate, a listmenu or any other input with an appropriate name and a submit button. Now open the FX Do Rate Single sb from the FX Poll and Ratings submenu in the server behaviors palette and apply it. In case of an array of rating forms select the entire structure and apply the Repeat Region.

Applying

Form: Select here the used form.
Connection: Select here the used connection, usually the same one used for the recordsets.
Update Table: Select here the candidates table where the rating will be updated.
Rating Column: Select here the column used for the rating or votes to be recorded and updated.
Counter Column: Select here the column used to count voters to be updated.
Where Column: Select here the candidate unique identifier usually an id.
Rating Element: Select here the name of the element used to give a score.
IP Table: Select here the table used to record the user's IP.
IP Column: Select here the name of the column where IPs are recorded. Since there will be only one column it will be already selected.
Display Recordset: Select here the recordset used to display the item candidates.
Cookie Name: Define the name of a cookie to save the user ip.
Referrer: In case of a single rating like in a detail page the referrer must be represented by the variable used to select the specific record, in case of an array of single ratings this must be represented by the identifier recordset source.
Array Style: Check this box if you are going to create an array of single ratings.
Close Poll: This checkbox is used in case you want to close the poll and show only the results.
Redirect To: Define here the redirection page after the rate is applied.

The Hide Rating Form sb is provided if you want to hide the rating form after the user submitted a rating.
It would be a good thing to add a Do Not Cache code in this page. You may find one for PHP here and some for ASP at the Adobe Exchange.

After this you may use the object FX Display Average for Single in the same page or in another.

by FELIXONE