Jump to content

Recommended Posts

submission code:

<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid."");
while($row = mysql_fetch_array($sql)){
$id =$row["id"];
?>
<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 type="text/javascript">
$(document).ready(function(){
	$(".update<?php echo $id; ?>").validate({
		debug: false,

		submitHandler: function(form) {
			// do other stuff for a valid form
			$.post('update.php', $(".update<?php echo $id;?>").serialize(), function(data) {
				$("#price").load("index.php #price");$("#total").load("index.php #total");
			});
		}
	});
});
</script>
    <?php
}
?>

form:

 <?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid."");
while($row = mysql_fetch_array($sql)){
$product = $row["product123"];
$price1 = $row["price"];
$id = $row["id"];
$qty = $row["quantity"];
if($product !=""){



?>

<form action="" class="update<?php echo $id; ?>" method="POST">
<input name="id" type="hidden" value="<?php echo $id; ?>" />
Quantity 
<input name="qty" type="text" value="<?php echo $qty; ?>" size="2" />$
<input name="price" type="text" value="<?php echo $price1; ?>" size="6" />
  <input type="submit" name="update" id="update" value="update" />
</form>

.

 

so my problem is that only everyother time does the page actually not refresh.......so one time it does and database doesn't update......second time it doesn't refresh and it updates(this is what I want).  why is it doing this?  is it because it is inside a div that gets refreshed?  if this is the problem....how do I fix it?

Link to comment
https://forums.phpfreaks.com/topic/256389-help-with-form-submission/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.