User Profile

Collapse

Profile Sidebar

Collapse
dobsun
dobsun
Last Activity: Sep 23 '07, 04:21 PM
Joined: Sep 23 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DONE thank you! correct one:
    Code:
    <?
    $q="SELECT * FROM product ";
    $r=mysql_query($q);
    $num=mysql_numrows($r);
    ?>
    name,instock,unitprice,value
    <br>
    <?
    $i=0;
    while ($i < $num) {
    $name=mysql_result($r,$i,"name");
    $instock=mysql_result($r,$i,"instock");
    $price1=mysql_result($rsklad,$i,"price1");
    echo $name;
    echo
    ...
    See more | Go to post
    Last edited by Dormilich; Sep 27 '10, 07:19 PM.

    Leave a comment:


  • Actualy I don't have problem to sum rows in mysql, I could sum it like this :
    Code:
    $q1="SELECT  sum(productsum) as a FROM product ";
    $r1=mysql_query($q1);
    $a= mysql_fetch_array($r1); 
    echo $a['a'];
    My problem is to show the SUM of all variables $value, see 1st post;
    One sugestion is to make as follow:
    Code:
     $value[$i]=$instock*$price1;
    But now I must calculate ... something lake this:...
    See more | Go to post
    Last edited by Dormilich; Sep 27 '10, 07:19 PM.

    Leave a comment:


  • dobsun
    started a topic How to calculate the sum of the values in a loop
    in PHP

    How to calculate the sum of the values in a loop

    MY QUESTION: HOW TO SUM TOTAL VALUE OF ALL ROWS?
    MY CODE:
    [code=php]<?
    $q="SELECT * FROM product ";
    $r=mysql_query( $q);
    $num=mysql_numr ows($r);
    ?>
    name,instock,un itprice,value
    <br>
    <?
    $i=0;
    while ($i < $num) {
    $name=mysql_res ult($r,$i,"name ");
    $instock=mysql_ result($r,$i,"i nstock");
    $price1=mysql_r esult($rsklad,$ i,"price1");...
    See more | Go to post
    Last edited by pbmods; Sep 23 '07, 01:26 PM. Reason: Added CODE tags.
No activity results to display
Show More
Working...