here is whole code:
<?php
session_start();
require_once "connect.php";
if(isset($_SESSION['logged'])){
// Query member data from the database and ready it for display
$cid = $_SESSION['complete'];
$academy = $_SESSION['academy'];
$sql = mysql_query("SELECT * FROM login where academy ='$academy'");
while($row = mysql_fetch_array($sql)){
$date =$row["date"];
if ($date !=="".date('m-d-Y')){echo '<meta http-equiv="REFRESH" content="0;url=login.php">';
exit(); }
}
}else{
echo '<meta http-equiv="REFRESH" content="0;url=login.php">';
exit();
}
echo $cid;
echo $academy;
if($_POST['total']){
$total = $_POST['total'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
$("#cash").click(function(){
// Logic to determine the form is ok to submit.
$("#types").hide();
$("#cash1").show();
});
});
</script> <script>
$(document).ready(function () {
$("#Check").click(function(){
// Logic to determine the form is ok to submit.
$("#types").hide();
$("#Check1").show();
});
});
</script> <script>
$(document).ready(function () {
$("#credit").click(function(){
// Logic to determine the form is ok to submit.
$("#types").hide();
$("#Credit1").show();
});
});
</script> <script>
$(document).ready(function () {
$("#Gift").click(function(){
// Logic to determine the form is ok to submit.
$("#types").hide();
$("#Gift1").show();
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#myform").validate({
debug: false,
submitHandler: function(form) {
// do other stuff for a valid form
$.post('', $("#myform").serialize(), function(data) {
});
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#myform2").validate({
debug: false,
submitHandler: function(form) {
// do other stuff for a valid form
$.post('payment.php', $("#myform2").serialize(), function(data) {
$("#types").show();
$("#cash1").hide();
$("#Credit1").hide();
$("#Check1").hide();
$("#Gift1").hide();
$("#more").load("collect.php #more");
$("#more").load("collect.php #more");$("#more").load("collect.php #more");$("#more").load("collect.php #more");
$("#more1").load("collect.php #more1");
});
}
});
});
</script>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
}
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}
/* ~~ this fixed width container surrounds the other divs ~~ */
.container {
width: 960px;
background: #FFF;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
}
/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
background: #ADB96E;
}
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
*/
.content {
padding: 10px 0;
}
/* ~~ The footer ~~ */
.footer {
padding: 10px 0;
background: #CCC49F;
}
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<script src="SpryAssets/SpryAccordion.js" type="text/javascript"></script>
<link href="SpryAssets/SpryAccordion.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="content">
<p>Please select payment type:</p>
<p> </p>
<?php setlocale(LC_MONETARY, "en_US");
echo money_format("The total is %n", $total);?>
<p><br />
<br /> <form id="myform" name="myform" method="post" >
<div class='label1' id='types'>
<input type="submit" name="type" value="Cash" id="cash" onclick="textchanged1()" />
<input type="submit" name="type" value="Credit Card" id="credit" onclick="textchanged2()" />
<input type="submit" name="type" value="Check" id="Check" onclick="textchanged3()" />
<input type="submit" name="type" value="Gift Card" id="Gift" onclick="textchanged4()" />
</div>
</form>
<br />
<form id="myform2" name="myform2" method="post" >
<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['complete']."' && product123 !=''");
while($row = mysql_fetch_array($sql)){
$product = $row["product123"];
$price1 = $row["price"];
$id = $row["product_id"];
$qty = $row["quantity"];
$month = date("F Y");
$day = date("d");
$year = date("Y");
$date = date("Y-m-d");
?>
<input name="product[]" type="hidden" value="<?php echo $product; ?>" />
<input name="academy[]" type="hidden" value="<?php echo $academy; ?>" />
<input name="month[]" type="hidden" value="<?php echo $month; ?>" />
<input name="day[]" type="hidden" value="<?php echo $day; ?>" />
<input name="year[]" type="hidden" value="<?php echo $year; ?>" />
<input name="date[]" type="hidden" value="<?php echo $date; ?>" />
<input name="price[]" type="hidden" value="<?php echo $price1; ?>" />
<input name="id[]" type="hidden" value="<?php echo $id; ?>" />
<input name="qty[]" type="hidden" value="<?php echo $qty; ?>" />
<?php
}
?> <input type="hidden" name="total" id="total" value="<?php echo $total; ?>" />
<div class='label1' id='cash1' style="display:none">
Please enter value given<br />
do not enter commas (,) or dollar signs ($)
<br />
<input type="text" name="payment1" id="payment" />
<input type="hidden" name="type1" id="Cash2" />
<input name="submit1" type="submit" value="Checkout" />
</p></div> <div class='label1' id='Credit1' style="display:none"> Please enter value given
<br />
do not enter commas (,) or dollar signs ($)
<br />
<input type="text" name="payment2" id="payment" />
<input type="hidden" name="type2" id="Credit2" />
<input name="submit2" type="submit" value="Checkout" />
</p></div> <div class='label1' id='Check1' style="display:none"> Please enter value given
<br />
do not enter commas (,) or dollar signs ($)
<br />
<input type="text" name="payment3" id="payment" />
<input type="hidden" name="type3" id="Check2" />
<input name="submit3" type="submit" value="Checkout" />
</p></div> <div class='label1' id='Gift1' style="display:none"> Please enter value given
<br />
do not enter commas (,) or dollar signs ($)
<br />
<input type="text" name="payment4" id="payment" />
<input type="hidden" name="type4" id="Gift2" />
<input name="submit4" type="submit" value="Checkout" />
</p></div>
</form>
<?php echo $total; ?>
<script type="text/javascript">
function textchanged1(){
var textTyped1 = document.getElementById('cash').value;
document.getElementById('Cash2').value = textTyped1;
}
</script> <script type="text/javascript">
function textchanged2(){
var textTyped2 = document.getElementById('credit').value;
document.getElementById('Credit2').value = textTyped2;
}
</script> <script type="text/javascript">
function textchanged3(){
var textTyped3 = document.getElementById('Check').value;
document.getElementById('Check2').value = textTyped3;
}
</script> <script type="text/javascript">
function textchanged4(){
var textTyped4 = document.getElementById('Gift').value;
document.getElementById('Gift2').value = textTyped4;
}
</script>
<script type="text/javascript">
function textchanged(){
var textTyped = document.getElementById('pay123').value;
document.getElementById('pay1234').value = '<?php echo $total; ?>' - textTyped;
}
</script>
<br />
you still need:<div id="more">
<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(amount) AS total FROM payment where cart_id='$cid'");
while($row = mysql_fetch_array($sql)){
$amount123 = $row["total"];
?>
<?php
}
$left=$total-$amount123;
?></div>
<div id="more1">
<?php echo $left;
?>
<p>
</p>
<p> </p>
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<!-- end .content --></div>
<!-- end .container --></div>
<script type="text/javascript">
var Accordion1 = new Spry.Widget.Accordion("Accordion1");
</script>
</body>
</html>
$total is towards top, and the code is towards bottom. it supposed to refresh the div witch I want to update the total then.