Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7948365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:42:11+00:00 2026-06-04T01:42:11+00:00

I have an array of data that I’m getting from this form (form.php): <?

  • 0

I have an array of data that I’m getting from this form (form.php):

<?
   include"connect.php";
   $sql = "select * from tbsatpor ";
   $qry = mysql_query($sql);
   echo"<form name='submit' method='POST' action='proses.php'>";
   $no  = 1;
   while ($data = mysql_fetch_array($qry)){
      $nomor  = $no++;
      echo "<input type='text' name='kd_satpor[]' value='$data[kd_satpor]' > 
            <input type='text' name='kd_unor[]' value='$data[kd_unor]' >
            <input type='text' name='buy[]' value=''><br>";
   }
   echo"<input type='submit' name='submit' value='submit'></form>";
?>

Here’s resultpage.php:

<?
  echo "<table border='0' size=100%>
         <tr><td>CODE</td><td>BUY</td><td>UNOR</td><td>TOTAL SUM</td></tr>";
  for ($i=0; $i<count($_POST['buy']);$i++){
     $_session[$i] =  $_POST['kd_satpor'][$i];
     $_session[$_POST['buy'][$i]] =  $_POST['buy'][$i];
     $_session[$_POST['kd_unor'][$i]] =  $_POST['kd_unor'][$i];
     $total[i]  =  $_session[$_POST['kd_unor'][$i]] * $_session[$_POST['buy'][$i]];

     if($total[i]!=0){ 
        echo "<tr><td>".$_session[$i]."</td><td>" .$_session[$_POST['buy'][$i]]." X                
              </td><td>".$_session[$_POST['kd_unor'][$i]]."=</td><td>".$total[i]."</td>
              <td></tr>";
     }
  } 
  echo"</table>";
?>

The data array looks like this (the output of resultpage.php):

CODE   | BUY   | UNOR | SUM
+++++++++++++++++++++++++++++++
024K30 | 10000 | 2    | 20000 | => 10000 x 2 = 20000
024K31 | 2000  | 3    | 6000  | =>  2000 x 3 = 6000
024K32 | 5000  | 3    | 15000 | =>  5000 x 3 = 15000
                        TOTAL?

I want to create TOTAL SUM from the array and show the result from that code. How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:42:12+00:00Added an answer on June 4, 2026 at 1:42 am
    $finalTotal = 0;
    
    for ($i=0; $i<count($_POST['buy']);$i++)
    {
        ...
    
    
        $finalTotal += $total[i];
    }
    
    echo 'Final Total: ' . $finalTotal;
    

    Also, use $_SESSION not $_session if you intend to use the PHP session and don’t forget to run any POST data through htmlentities() before you echo it out onto a page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable that contains an array from form data, seen below: $option1
I have a php array that has a bunch of data that I need
I have a model that I'm trying to retrieve an array of data from,
I have an array of data that looks like this: 2008, Honda, Accord, Used,
I have three dimensional array of data that is generated from web server logs
I have an array of data that I'll echo to a page using PHP,
I currently have an array data structure that I iterate over like this, calling
I would like to select elements in my data array that have a specific
I have an array that is taken from an image using exif_read_data($image, 0, true)
I have this array Array ( [data] => Array ( [0] => Array (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.