A Php Code needs to be converted in coldfusion

Discussion in 'Programming' started by gavy, Nov 6, 2008.

?

What you think Adobe Will Do for Coldfusion?

Poll closed Feb 4, 2009.
  1. It will Rise?

    0 vote(s)
    0.0%
  2. It will Decline

    0 vote(s)
    0.0%
  3. Consider It Dead

    0 vote(s)
    0.0%
  4. Make Robust Application Developerment Using AJAx and Much More

    100.0%
Multiple votes are allowed.
  1. #1
    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;
     
    gavy, Nov 6, 2008 IP
  2. ariefsyu

    ariefsyu Active Member

    Messages:
    192
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    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
     
    ariefsyu, Nov 16, 2008 IP