First of all, I am working with two files.

test.html
Code:
<!DOCTYPE html>

<html><head><title>Test page</title>

<link rel='stylesheet' href='css/style.css'>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script>
$(function() {

$("#sides").change(function() {
	$("#color").load("getter.php?choice=" + escape($("#sides").val()) + "&fetch=color");
	$("#papertype").load("getter.php?choice=" + escape($("#sides").val()) + "&fetch=papertype");
	$("#deliverytime").load("getter.php?choice=" + escape($("#sides").val()) + "&fetch=deliverytime");
	$("#quantity").load("getter.php?choice=" + escape($("#sides").val()) + "&fetch=quantity");
    $.get("getter.php?fetch=price&sides=" + escape($("#sides").val()) + "&choice=" + escape($("#sides")) + "&color=" + escape($("#color").val()) + "&papertype=" + escape($("#papertype").val()) + "&deliverytime=" + escape($("#deliverytime").val()) + "&quantity=" + escape($("#quantity").val())).then(function(response){ $("#price").text(response); })
});


});

</script>

</head><body>
<div id="page-wrap">
Sides: <select id="sides">
	<option selected value="base">Please Select</option>
	<option value="Single Sided">Single Sided</option>
	<option value="Double Sided">Double Sided</option>
</select>

<br /><br />

Color: <select id="color">
	<option>Please choose from above</option>
</select>
<br /><br />
Paper type: <select id="papertype">
	<option>Please choose from above</option>
</select>
<br /><br />
Delivery time: <select id="deliverytime">
	<option>Please choose from above</option>
</select>
<br /><br />
Quantity: <select id="quantity">
<option>Please choose from above</option>
</select>
<br /><br />
<b>Price:</b> $<p id="price">0</p>
</div>
</body>
</html>
getter.php
PHP Code:
<?php

    $username 
"root";
    
$password "";
    
$hostname "localhost";
    
    
$dbhandle mysql_connect($hostname$username$password) or die("Unable to connect to MySQL");
    
$selected mysql_select_db("db"$dbhandle) or die("Could not select examples");
    
$fetch mysql_real_escape_string($_GET['fetch']);
    
$choice mysql_real_escape_string($_GET['choice']);
    if (
$fetch == "price") { 
    echo 
"yes, i know it";
    
$color mysql_real_escape_string($_GET['color']);
    echo 
$color;
    
$papertype mysql_real_escape_string($_GET['papertype']);
    
$deliverytime mysql_real_escape_string($_GET['deliverytime']);
    
$quantity mysql_real_escape_string($_GET['quantity']);
    }
    
    
//testing

    
if ($fetch == "color"$query "SELECT DISTINCT color FROM a5letterhead WHERE sides='$choice'";
    if (
$fetch == "papertype"$query "SELECT DISTINCT papertype FROM a5letterhead WHERE sides='$choice'";
    if (
$fetch == "deliverytime"$query "SELECT DISTINCT deliverytime FROM a5letterhead WHERE sides='$choice'";
    if (
$fetch == "quantity"$query "SELECT DISTINCT quantity, rate FROM a5letterhead WHERE sides='$choice'";
    if (
$fetch == "price"$query "SELECT price FROM a5letterhead WHERE color='$color' AND papertype='$papertype' AND deliverytime='$deliverytime' AND quantity='$quantity'";
    
$result mysql_query($query);
    
$row mysql_fetch_array($result);
    echo 
$row{'price'};
    echo 
$query;

    while (
$row mysql_fetch_array($result)) {
           if (
$fetch == "color") echo "<option value=".$row{'color'}.">" $row{'color'} . "</option>";
        if (
$fetch == "papertype") echo "<option value=".$row{'papertype'}.">" $row{'papertype'} . "</option>";
        if (
$fetch == "deliverytime") echo "<option value=".$row{'deliverytime'}.">" $row{'deliverytime'} . "</option>";
        if (
$fetch == "quantity") echo "<option value=".$row{'quantity'}.">" $row{'quantity'} . " copies (" $row{'rate'} . " per copy)</option>";
         if (
$fetch == "price") {
    
$color mysql_real_escape_string($_GET['color']);
    
$papertype mysql_real_escape_string($_GET['papertype']);
    
$deliverytime mysql_real_escape_string($_GET['deliverytime']);
    
$quantity mysql_real_escape_string($_GET['quantity']);
    
$sides mysql_real_escape_string($_GET['sides']);
    echo 
$row['price']; echo $query;
    }
        }
        
?>
Now what is happening is that when I select an option from the first drop down menu (id: sides) all the following drop downs change accordingly (fetch values from the database, all good there). But the issue arises when I am trying to update the price, now the algo is supposed to go through each option selected in the form and extract the right price from the database but instead of taking the latest choices of dropdown options ( as can be seen on the display ) it takes the previous one which would give us the price of the last choice of dropdown options selected.

What can we do about this, I am not an expert in jQuery or anything so please be easy on me