Forum Moderators: coopster
<tr>
<td>Product 1</td>
<td><input type="text" value="4080" name="3" style="width:40px;" /></td>
<td>Product 2</td>
<td><input type="text" value="970" name="18" style="width:40px;" /></td>
</tr>
<script type="text/javascript">
// <![CDATA[
$(function() {
$("#pricelist_edit").submit(function(){
var dataString = $(this).serialize();
alert(dataString);
$.ajax({
type: "POST",
url: "includes/process/pricelist.php",
data: dataString,
dataType: "json",
cache: false,
success: function(response) {
//alert (JSON.stringify(response));
if (response.result === "success" ) {
alert(Success);
}
else if (response.result === "error") {
alert("There has been an error, please contact support");
}
}
});
return false;
});
});
// ]]>
</script>
if(isset($_POST['pricelist_edit'])){
foreach($_POST as $key => $value) {
$data[$key] = clean($value);
}
$id = $data['id'];
$price = $data['price'];
foreach($id as $key => $price) {
$sql = "UPDATE table SET product_price='$price' WHERE product_id='$id'";
$result = mysql_query($sql) or die(mysql_error());
}
if ($result) {
$arr = array("result" => "success");
echo json_encode($arr);
} else {
$arr = array("result" => "error");
echo json_encode($arr);
}}