Results 1 to 2 of 2

Thread: Sum of input will appear in a total input textfield

  1. #1
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default Sum of input will appear in a total input textfield

    Good day!

    I have a problem in adding codes in my php codes, but i have the concept of codes that i want to add in my php codes, but I don't know if it is right. Kindly check my codes thank you.

    I attached my whole codes for better understanding

    and here is the codes I want to add:
    Code:
    <?php
    $rexist = 0;
    if($_POST["clt_no"])
    {
       $opname = $_POST["opname"];
       $inqty = $_POST["inqty"];
       $outqty = $_POST["outqty"];
       
       $totalarr = count($opname) - 1;
        for($ctr=0; $ctr < $totalarr; $ctr++)
            {
            $inqty[$ctr] = (float) $inqty[$ctr];
            $outqtyqty[$ctr] = (float) $outqty[$ctr];
            
             $query = "INSERT INTO clt_traceability (operation_name, input_qty, clt_transact_id) VALUES ('" . $opname[$ctr] . "',  '" . $inqty[$ctr] . "', '" . $outqty[$ctr] . "', '" . $clt_transact_id . "')";
            $result = mysql_query($query);
            }   
            
        $query = "SELECT * FROM clt_transact WHERE  clt_no = '" . $_POST["clt_no"] . "'";
        $result_no = mysql_query($query);
            if($result_no)
                {
                if(mysql_num_rows($result_no) > 0 )
                {
                $clicking_input = 0;
                $clicking_total = 0;
                
                $query = "SELECT t.input_qty AS clicking_input FROM clt_traceability t, p WHERE t.clt_transact_id = p.clt_transact_id AND t.operation_name '02 Clicking' AND p.clt_no='" . $_POST["clt_no"] . "'";
                $resultyield = mysql_query($query);
                if($resultyield)
                    {
                        if(mysql_num_rows($resultyield) > 0)$clicking_input =mysql_result($resultyield,0,"clicking_input");
                    }
              /*  $query = "SELECT SUM(t.input_qty) AS clicking_input FROM clt_traceability t, clt_transact p WHERE t.clt_transact_id = p.clt_transact_id AND t.operation_name '02 Clicking' AND p.clt_no='" . $_POST["clt_no"] . "'";
                $resultyield = mysql_query($query);
                if($resultyield)
                    {
                        if(mysql_num_rows($resultyield) > 0)$clicking_input =mysql_result($resultyield,0,"clicking_input");
                    }*/
                $query = "SELECT operation_name FROM clt_traceability t, clt_transact c WHERE t.operation_name = '02 Clicking Total' AND t.clt_transact_id = c.clt_transact_id";
                $result = mysql_query($query);
                if($result > 0)
                {           
                $clicking_total = $clicking_input;
                //pano automatic mag eecho o mag aappear ung sum ng inqty sa inqty ng clicking total
                }
                }
        }
    }
    $rexist = 0;
    ?>
    I want to happen is all the input qty that the user insert in input qty textfield will sum and the result will appear in operation2_total in input_qty textfield.

    I don't know how thus the result should be appear automatically in the input qty of operation2_total and if my code is correct.

    Thank you
    Last edited by rhodarose; 12-15-2010 at 04:28 AM.

  2. #2
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    I have 5 operation name: operation1,operation2,operation2_total,operation3,operation4,operation5. As you notice I have a operation2_total

    How can I add the input qty of operation2 and the result will be appear in input_qty of operation2_total.

    Thank you
    Last edited by rhodarose; 12-15-2010 at 05:15 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •