I have alittle PHP snippet in a While loop and i am getting into problems while converting it $sql = "select rating from r_ratings where iid = $iid"; $result3 = mysql_query($sql ,$db); if ($myrow2 = mysql_fetch_array($result3)) { do { $ratetotal = $ratetotal + $myrow2["rating"]; $ratecount++; } while ($myrow2 = mysql_fetch_array($result3)); } $newrate = $ratetotal / $ratecount;
I assume you can handle the <cfquery> tags, so I will not write complete code for the <cfquery>. <cfquery name=result3> select rating from r_ratings where iid = $iid </cfquery> Code (markup): <cfset ratecount =0> <cfset ratetotal =0> <cfoutput query=result3> <cfset ratetotal = ratetotal + rating> <cfset ratecount = inc(ratecount)> </cfoutput> <cfset newrate = ratetotal / ratecount> Code (markup): Thats it. I wish i could help you. Arief