Skip to main content
Inspiring
November 6, 2008
Question

A Little help with Code needed

  • November 6, 2008
  • 1 reply
  • 491 views
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;
This topic has been closed for replies.

1 reply

Inspiring
November 6, 2008
newchickinCF wrote:
> I have alittle PHP snippet in a While loop and i am getting into problems while
> converting it

So what problem are you having?
Inspiring
November 6, 2008
do while stuff is troubling me, i visited livedocs to get that in something but i am getting unsuccessfull.

ere is my try:

<cfscript>
do
{
ratetotal = #ratetotal# + #showRate.rating#;
ratecount++;
}
while(#showrate.recordcount#);
</cfscript>
<cfset newrate = #ratetotal# / #ratecount#>

but that does seems to work either