Ciao.

Faccio riferimento al seguente articolo web per l'implementazione di un sistema di rating in pagine ASP:

http://www.devarticles.com/c/a/ASP/A...stem-With-ASP/

Sono riuscito a personalizzarlo alle mie esigenze, adattandolo a un DB MySQL e utilizzando un'unica tabella, ma non riesco a capire perchè quando visualizzo per ciascun record il proprio rating, succede che il record seguente a quello che ha un rating ( quindi è stato valutato dai visitatori ) assuma come rating quello del record che lo precede.

Ad esempio:

Ho un record con rating 1 lo estraggo e quello immediatamente successivo anche se non ha nessuna valutazione, assume anche lui valore 1.

La estrazione è eseguita randomicamente con la sintassi BY RAND() prevista da MySQL.

Credo che il problema sia da individuare in questa porzione di codice che è quella che assegna le "stelline" a secondo del rating, ma non riesco a capire dove sia l'errore:

codice:
if Instr(1, CStr(avgRating), ".") > 0 then 

'The average rating is a decimal, we need to either 
'round the value up/down 

avgWhole = Left(CStr(avgRating), Instr(1, CStr(avgRating), ".")-1) 
decPart = Mid(CStr(avgRating), Instr(1, CStr(avgRating), ".")+1, 2) 

if decPart <> "" then 
'Work out whether or not we have to round this 
'rating up or down 

if CInt(decPart) >= 5 then 
decCalc = .5 
else 
decCalc = 0 
end if 

finalRating = CInt(avgWhole) + CCur(decCalc) 

else 
finalRating = avgRating 
end if 
else 
finalRating = avgRating 
end if 

'Setup the alt text for the images 
altText = "Average visitor rating of " & finalRating & " out of 10" 

for i = 1 to CInt(finalRating) 
Response.Write "[img]rating_on.gif[/img]" 
next 

if CInt(finalRating) <> finalRating then 
'This article has a .5 rating, such as 5.5 
Response.Write "[img]rating_half.gif[/img]" 

for i = CInt(finalRating)+2 to 8 
Response.Write "[img]rating_off.gif[/img]" 
next 
else 
for i = CInt(finalRating)+1 to 8 
Response.Write "[img]rating_off.gif[/img]" 
next 
end if 

if CInt(finalRating) <> finalRating then 
'This article has a .5 rating, such as 5.5 
Response.Write "[img]rating_half.gif[/img]" 

<h2><%=rs.Fields(1).Value%></h2> 
Rated: <%=rs.Fields(0).Value%>
Grazie!