girish_327
Posts: 108
|
| Posted: 06/18/2004, 4:47 AM |
|
Function rating_OnValidate()
if rating.ebook_id.value = CCDLookup("ebook_id","rating","user_id=" & CCToSQL(CCGetUserID(),"Integer"), DBebook) AND rating.ip.value = Request.ServerVariables("REMOTE_ADDR") then
rating.Errors.addError("You Can't Rate Same eBook Twice.")
else
Dim SQL,ebookid,rate
Dim Connection
ebookid = rating.ebook_id.value
rate = rating.rate.value
SQL= "update ebook set rating=rating+" & rating.rate.value & ", rating_count=rating_count+1 where ebook_id=" & rating.ebook_id.value
Set Connection = New clsDBebook
Connection.Open
Connection.Execute(SQL)
Connection.Close
Set Connection = Nothing
end if
End Function
Please Help Me out regardign Above Code. I have Made rating system for ebook Project. But I am facing follwigng problems
1) User only rate ebook once
2) After inserting in to Rating I want update ebook rating Counter and Rate Value in ebook Table
but above code have some mistake or something wrong that why its not validating if its validate then still its updating the counter.
Please Help Me what is the wrong in My Code.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
girish_327
Posts: 108
|
| Posted: 06/19/2004, 11:19 PM |
|
Solved My Self
Function rating_OnValidate() 'rating_OnValidate @80-2C9E7A95
'Custom Code @116-73254650
' -------------------------
' Write your own code here.
if rating.ebook_id.value = CCDLookup("ebook_id","rating","ebook_id=" & ebook.ebook_id.value & "AND user_id =" & CCGetUserID(),DBebook) then
rating.Errors.addError("You Can't Rate Same eBook Twice.")
else
Dim SQL,ebookid,rate
Dim Connection
ebookid = rating.ebook_id.value
rate = rating.rate.value
SQL= "update ebook set rating=rating+" & rating.rate.value & ", rating_count=rating_count+1 where ebook_id=" & rating.ebook_id.value
Set Connection = New clsDBebook
Connection.Open
Connection.Execute(SQL)
Connection.Close
Set Connection = Nothing
end if
' -------------------------
'End Custom Code
End Function
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
|