how to multiply the numbers inside for loop when is loop?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xiu
    New Member
    • Nov 2007
    • 1

    #1

    how to multiply the numbers inside for loop when is loop?

    Give me a hand please!!

    The purpose of this code is to get the totall price, but I don't know how to multiply $orderAmount ,$menuPrice inside for loop. and I also get problem to echo the result only once.
    [code=php]
    for ($i=1; $i<=$numRowsMen uid;++$i){
    $rowOrderInfo=m ysql_fetch_asso c($resultOrderI nfo);
    $orderAmount=$r owOrderInfo['orderamount'];

    $resultMenuInfo = mysql_query("SE LECT * FROM menuinfo where id=$menuId");
    while ($rowsMenuInfo= mysql_fetch_ass oc($resultMenuI nfo)){
    $menuPrice=$row sMenuInfo['menuprice'];

    }
    }[/code]
    Last edited by pbmods; Nov 21 '07, 04:22 AM. Reason: Added CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Xiu. Welcome to TSDN!

    Where do you define $menuid? It seems as though your script keeps running the exact same query every iteration.

    Comment

    Working...