I have write a coding that it can generate the total quantity automatically base on the gender.I write it by using a javascript. But I dont know how to get that data to be store into the database by using php All the coding is in one page.
Here is my code
     <script type = "text/javascript">
     function updateTotal() {
     var genderPart=0;
     var totalPart =0;
    function checkGender(){
    if(document.getElementById('gender').value=='GIRL'){
    genderPart+=1;
    }
    if(document.getElementById('gender').value=='BOY'){
    genderPart+=2;
    }
    }//end of checking gender part
     checkGender();
     var totalPart= genderPart; 
     document.getElementById('totalPart').innerHTML = totalPart;
      }//end of my main  total function
    </script>
     <form action="" method="post" name="nomineeform">
     <table align="center" width="800" border="2" >
     <tr>
     <td align="right"><b>Gender :</b></td>
     <td><select name="gender" id="gender"  onchange="updateTotal()">
                  <option selected="selected" value="">--Choose--</option>
                  <option value="GIRL" >GIRL</option>
                  <option value="BOY" >BOY</option>
                </select></td> 
            </tr>
             <tr>
                <td align="right"><b>Type of Animal :</b></td>
                <td><select name="animal" id="animal" onchange="updateTotal()">
                <option selected="selected" value="">--Jenis Haiwan--</option>
                <?php
                    $get_animal = "select * from animal";
                    $run_animal = pg_query($get_animal);
                        while ($row_animal=pg_fetch_array($run_animal))
                        {
                            $animal_id = $row_animal['animal_id'];
                            $animal_name = $row_animal['typeanimal'];
                            echo "<option value='$animal_id'>$animal_name</option>";
                        }
                    ?>
                </select></td>
            </tr>
             <tr>
                <td align="right"><b>Quantity :</b></td>
                <td><input type="text" name="quantity" size="60" value = "<?php echo $_GET['totalPart'];?>" required="required"/></td>
            </tr>
            <tr></tr>
            <tr align="center">
                <td colspan="8"><input type="submit" name="nominee" class="btn btn-info" value=" TERUSKAN " onclick="return val();"/></td>
            </tr>
    </table>
</form>
            <?php 
if(isset($_POST['nominee']))
    {
        $connection = pg_connect("user = postgres password = syafiqah26 port = 5433 dbname = bengkel2 host = localhost");
          $name = pg_escape_string($_POST['name']);
        $gender =pg_escape_string($_POST['gender']);
        $age= pg_escape_string($_POST['age']);
        $cust_id= pg_escape_string($_POST['hidden']);
        $animal= pg_escape_string($_POST['animal']);
        $quantity= pg_escape_string($_POST['quantity']);
        $query = "INSERT INTO nominee(name,age,gender,cust_id,animal,quantity)
        VALUES('$name','$age','$gender','$cust_id','$animal','$quantity')";
        $result = pg_query($connection,$query);
       }
 
     
     
     
    