Trying to check Unique Category Title Using Ajax and Jquery.
JQuery and ajax stuff
<script>
$(document).ready(function(){
$('#category_title').change(function(){
var category_title = $(this).val();
$.ajax ({
url : "ajax_calls.php",
method : "POST",
data : {category_title :category_title },
dataType: "text",
success:function(html)
{
$('#availablity').html(html);
}
});
});
</script>
ajax_call.php
<?php
include 'commands.php';
if (isset($_POST['category_title'])) {
$category_title = $_POST['category_title'];
$obj= new commands();
$result= $obj->check_category_title($category_title);
if (empty($result)) {
echo "<span class='status-available' style='color:green;'> Username Available.</span>";
} else {
echo "<span class='status-not-available' style='color:red;'>Category Already Exist</span>";
}
}
?>
HTML stuff
<form action="" method="post" id="my_form" enctype="multipart/form-data">
<div class="form-group">
<label class="tags">Category Title</label>
<input type="text" name="category_title" class="form-control" id="category_title"><span id="availablity"></span>
<p class="errorMsg"><?php if(isset($errorTitle) && $errorTitle== 1){echo "Field Required" ;} ?> </p>
</div>
</form>
MySQLi stuff
function check_category_title($category_title){
$stmt = $this->con->prepare("SELECT category_title FROM `nm_category` WHERE category_title='$category_title'");
$stmt->execute();
$result=$stmt->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
I want to prevent user to submit if the category already exist in table else allow user to submit
Make changes like below in your php code :
if (empty($result)) {
echo "<span class='status-available' style='color:green;'> Username Available.</span>";
//show submit button if no data found
echo "<input type='submit' value='submit'>";
} else {
echo "<span class='status-not-available' style='color:red;'>Category Already Exist</span>";
//disabled button to prevent submit if category exist
echo "<input type='submit' value='submit' disabled='disabled'>";
}
I have a form that is echoed out from the database, but the issue is that when I try to submit, only the first echoed form submits and the rest doesn't. Below is my code.
editquestion.phh
<thead>
<tr>
<th style="width: 5%;">S/N</th>
<th style="width: 20%;">QUESTION</th>
<th style="width: 40%;">ANSWER</th>
<th style="width: 30%;">KEYWORDS</th>
<th style="width: 5%;">SAVE/UPDATE</th>
</tr>
</thead>
<tbody>
<?php
$sql = $db->prepare("SELECT * FROM questions");
$result = $sql->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC))
{
$quiz_id = $row['quiz_id'];
$question = $row['question'];
$answer = $row['answer'];
$keywords = $row['keywords'];
echo '<form action="updatequestion.php" method="post" enctype="multipart/form-data">
<tr>
<td><input style="width: 50%" type="text" name="cid" id="cid" value="'.$quiz_id.'"></td>
<td><input type="text" name="question" id="question" value="'.$question.'"></td>
<td><input type="text" name="answer" id="answer" value="'.$answer.'"></td>
<td><input type="text" name="keywords" id="keywords" value="'.$keywords.'"></td>
<td><input type="submit" name="qupdate" class="qupdate" value="Update"></td>
</tr>
</form>';
}
?>
</tbody>
</table>
qupdate.js
$(document).ready(function() {
$('.qupdate').click(function() {
question = $('#question').val();
answer = $('#answer').val();
keywords = $('#keywords').val();
id = $('#cid').val();
$.ajax({
type: "POST",
url: "updatequestion.php",
data: "cid="+id+"&question="+question+"&answer="+answer+"&keywords="+keywords,
success: function(html){
if(html = "true")
{
$('.qupdate').css("opacity", "1");
}
else
{
alert("not successful");
}
},
beforeSend: function(){
$('.qupdate').css("opacity", "0.5");
}
});
return false;
});
});
Just added the code for updatequestion.php.
<?php
session_start();
require_once("db.php");
$db = new MyDB();
if (isset($_POST['question']) || isset($_POST['answer']) || isset($_POST['cid']))
{
$id = strip_tags(#$_POST['cid']);
$cname = strip_tags(#$_POST['question']);
$cunit = strip_tags(#$_POST['answer']);
$keywords = strip_tags(#$_POST['keywords']);
if (empty($cname) || empty($cunit))
{
echo "fill";
}
else
{
$sql = $db->prepare("UPDATE questions SET question = ?, answer = ?, keywords = ? WHERE quiz_id = ?");
$sql->bindParam(1, $cname, SQLITE3_TEXT);
$sql->bindParam(2, $cunit, SQLITE3_TEXT);
$sql->bindParam(3, $keywords, SQLITE3_TEXT);
$sql->bindParam(4, $id, SQLITE3_INTEGER);
$result = $sql->execute();
if ($result)
{
echo "true";
}
else
{
echo "false";
}
}
}
?>
But the ajax seems to only work for the first echoed data and doesn't seem to submit the rest. How do I solve this?
Thanks in advance.
Add class dynamic-form to form tag and remove id from all fields:
echo '<form class="dynamic-form" action="updatequestion.php" method="post" enctype="multipart/form-data">
<tr>
<td><input style="width: 50%" type="text" name="cid" value="'.$quiz_id.'"></td>
<td><input type="text" name="question" value="'.$question.'"></td>
<td><input type="text" name="answer" value="'.$answer.'"></td>
<td><input type="text" name="keywords" value="'.$keywords.'"></td>
<td><input type="submit" name="qupdate" class="qupdate" value="Update"></td>
</tr>
</form>';
Update in JS
$(document).ready(function () {
$('.dynamic-form').on('submit', function () {
var formdata = $(this).serialize();
$.ajax({
type: "POST",
url: "updatequestion.php",
data: formdata,
success: function (html) {
//success
}
});
return false;
});
});
Here is solution of your problem :-
$('.qupdate').click(function() {
var question = $(this).closest("form").find('input[name=question]').val();
var answer = $(this).closest("form").find('input[name=answer]').val();
var keywords = $(this).closest("form").find('input[name=keywords]').val();
var id = $(this).closest("form").find('input[name=cid]').val();
});
It seems everyone here gave you almost the same answer, but it does not entirely satisfy your problem.
To give you the simplest answers:
What you are doing is bad practice by principle, because you should
not echo "forms"
Each form on the page has the same information
besides the inputs, which is wrong.
The correct solution:
Start using ajax post only for this purpose
Don't use FORM, instead just create a div for each question and have
the inputs there with the question id
Use a modal to edit the questions, that way when you close the
modal you reset the inputs in the modal, giving you the ability to
edit again a question and save it.
The solution you want right now:
editquestion.php
<thead>
<tr>
<th style="width: 5%;">S/N</th>
<th style="width: 20%;">QUESTION</th>
<th style="width: 40%;">ANSWER</th>
<th style="width: 30%;">KEYWORDS</th>
<th style="width: 5%;">SAVE/UPDATE</th>
</tr>
</thead>
<tbody>
<?php
$sql = $db->prepare("SELECT * FROM questions");
$result = $sql->execute();
while ($row = $result->fetchArray(SQLITE3_ASSOC))
{
$quiz_id = $row['quiz_id'];
$question = $row['question'];
$answer = $row['answer'];
$keywords = $row['keywords'];
echo '<tr>';
echo '<td><input style="width: 50%" type="text" name="cid" id="cid" value="'.$quiz_id.'"></td>';
echo '<td><input type="text" name="question" id="question" value="'.$question.'"></td>';
echo '<td><input type="text" name="answer" id="answer" value="'.$answer.'"></td>';
echo '<td><input type="text" name="keywords" id="keywords" value="'.$keywords.'"></td>';
echo '<td><input type="button" name="qupdate" class="qupdate" value="Update" onclick="doEdit('.$quiz_id.');"></td>';
echo '</tr>';
}
?>
</tbody>
</table>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit Question</h4>
</div>
<div class="modal-body">
<p>Edit your question:</p>
<p><input type="hidden" id="question_id" id="question_id" value=""></p>
<p><input type="text" id="question_text" value=""></p>
<p><input type="text" id="question_answer" value=""></p>
<p><input type="text" id="question_keywords" value=""></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" id="doupdate" class="btn btn-default">Update Question</button>
</div>
</div>
</div>
</div>
qupdate.js:
<script>
$(document).ready(function() {
function doEdit(question_id) {
/** POPULATE THE MODAL WITH THE QUESTION DATA **/
$.ajax({
type: "POST",
url: "getquestiondata.php", /** create this file, and return the question data from the database based on the "cid" **/
data: "cid="+question_id+",
success: function(response){
$('#question_id').val(response.cid);
$('#question_text').val(response.text);
$('#question_answer').val(response.answer);
$('#question_keywords').val(response.keywords);
}
});
}
/** DO THE ACTUAL UPDATE **/
$('#doupdate').click(function() {
var question_id = $('#question_id').val();
var question_text = $('#question_text').val();
var question_answer = $('#question_answer').val(),
var question_keywords = $('#question_keywords').val(),
$.ajax({
type: "POST",
url: "updatequestion.php",
data: "cid="+question_id+"&question="+question_text+"&answer="+question_answer+"&keywords="+question_keywords,
success: function(html){
if(html = "true")
{
$('.qupdate').css("opacity", "1");
$('#myModal').modal('toggle');
// Reset the modal inputs
$('#question_id').val("");
$('#question_text').val("");
$('#question_answer').val("");
$('#question_keywords').val("");
}
else
{
alert("not successful");
}
},
beforeSend: function(){
$('.qupdate').css("opacity", "0.5");
}
});
return false;
});
});
</script>
This code is untested, as I do not have your database or any information about the questions you store, however I am 90% positive that if you use this method it will work for you better than any other answer.
If I made some small typo or mistake, the code is very easy to edit and fix it.
FINAL NOTE: "updatequestion.php" is not the problem here, was never the problem.
Good luck!
As was mentioned by other people ID should be unique on the page.
In your case you can get whole form and serialize it's data:
$(document).ready(function() {
$('.qupdate').click(function() {
// Clicked $('.qupdate') is now $(this)
// But we should define $this variable if we want to be able to use it in callbacks.
// This is more efficient way instead of searching for $('.qupdate') in DOM again and again.
// Unless you want to set CSS for ALL .qupdate buttons in ALL forms.
var $this = $(this);
$.ajax({
type: "POST",
url: "updatequestion.php",
// find closest to .qupdate form and serialize it's data
data: $this.closest('form').serialize(),
success: function(html) {
// use double (or even tripple) equals operator if you want to compare, otherwise you'll just set html as "true"
// and it'll be always successful
if(html == "true") {
// We use $this variable here which we've defined earlier, and which, as we remember,
// stands for clicked $('.qupdate') button
$this.css("opacity", "1");
} else {
alert("not successful");
}
},
beforeSend: function() {
// We use $this variable here which we've defined earlier, and which, as we remember,
// stands for clicked $('.qupdate') button
$this.css("opacity", "0.5");
}
});
return false;
});
});
Update
Perhaps you send in response not exactly "true" or "false"?
In order to be sure that you don't send back any extra characters you should call exit after echo:
if ($result)
{
echo "true";
exit;
}
else
{
echo "false";
exit;
}
If you aren't sure you can simply remove this html check from JS since it never worked actually in your example:
// remove this if-else block
if(html = "true")
{
$('.qupdate').css("opacity", "1");
}
else
{
alert("not successful");
}
You can also check what you send and what you get using browser developer tools. For example in chrome press F12 and in the opened panel select Network tab. Now click button in any form and you'll see that new request was sent. Wait for it to complete - Status column should receive some number (200 if everything was ok). Now you can click on this request and see details. There is even video example =) https://www.youtube.com/watch?v=WOQDrGrd9H8
I try to help using Sanjay Kumar answer since you want to save per row
editquestion.php
<thead>
<tr>
<th style="width: 5%;">S/N</th>
<th style="width: 20%;">QUESTION</th>
<th style="width: 40%;">ANSWER</th>
<th style="width: 30%;">KEYWORDS</th>
<th style="width: 5%;">SAVE/UPDATE</th>
</tr>
</thead>
<tbody>
<?php
// assuming your database already connected here
$sql = $db->prepare("SELECT * FROM questions");
$result = $sql->execute();
while($row = $result->fetchArray(SQLITE3_ASSOC))
{
$quiz_id = $row['quiz_id'];
$question = $row['question'];
$answer = $row['answer'];
$keywords = $row['keywords'];
// enctype="multipart/form-data" is used if the form contains a file upload, and echo per line for clarity
echo '<form action="updatequestion.php" method="post">';
echo '<tr>';
echo '<td><input style="width: 50%" type="text" name="cid" value="'.$quiz_id.'"></td>';
echo '<td><input type="text" name="question" value="'.$question.'"></td>';
echo '<td><input type="text" name="answer" value="'.$answer.'"></td>';
echo '<td><input type="text" name="keywords" value="'.$keywords.'"></td>';
echo '<td><input type="submit" name="qupdate" class="qupdate" value="Update"></td>';
echo '</tr>';
echo '</form>';
}
?>
</tbody>
</table>
qupdate.js
// assuming you already loaded jquery library
$(document).ready(function()
{
$('.qupdate').click(function()
{
var id = $(this).closest("form").find('input[name=cid]').val();
var question = $(this).closest("form").find('input[name=question]').val();
var answer = $(this).closest("form").find('input[name=answer]').val();
var keywords = $(this).closest("form").find('input[name=keywords]').val();
var postData = {'cid' : id, 'question' : question, 'answer' : answer, 'keywords' : keywords};
$.ajax(
{
type: "POST",
url: "updatequestion.php",
data: postData,
success: function(response)
{
// note the '==' operator
if(response == "true")
{
$('.qupdate').css("opacity", "1");
}
else
{
console.log(response);
alert("not successful");
}
},
error: function(e)
{
console.log(e);
},
beforeSend: function()
{
$('.qupdate').css("opacity", "0.5");
}
});
return false;
});
});
updatequestion.php
<?php
session_start();
require_once("db.php");
$db = new MyDB();
if(isset($_POST['cid']) && isset($_POST['question']) && isset($_POST['answer']) && isset($_POST['keywords']))
{
$id = filter_input(INPUT_POST, 'cid', FILTER_SANITIZE_STRING);
$cname = filter_input(INPUT_POST, 'question', FILTER_SANITIZE_STRING)
$cunit = filter_input(INPUT_POST, 'answer', FILTER_SANITIZE_STRING)
$keywords = filter_input(INPUT_POST, 'keywords', FILTER_SANITIZE_STRING)
if($id == '' || $cname == '' || $cunit == '' || $keywords == '')
{
echo "one or more parameter is empty";
}
else
{
$sql = $db->prepare("UPDATE questions SET question = ?, answer = ?, keywords = ? WHERE quiz_id = ?");
$sql->bindParam(1, $cname, SQLITE3_TEXT);
$sql->bindParam(2, $cunit, SQLITE3_TEXT);
$sql->bindParam(3, $keywords, SQLITE3_TEXT);
$sql->bindParam(4, $id, SQLITE3_INTEGER);
$result = $sql->execute();
if ($result)
{
echo "true";
}
else
{
echo "false";
}
}
}
else
{
echo "wrong parameter";
}
?>
I add some comment in the code.
You can inspect element and check in console tab for additional message if something not working, and i add filter input function for some security and change the comparison for empty variable.
I hope this give you some idea.
You can use in some other way may be it works
$(document).on('click','.qupdate',function() {
var question = $(this).closest("form").find('input[name=question]').val();
var answer = $(this).closest("form").find('input[name=answer]').val();
var keywords = $(this).closest("form").find('input[name=keywords]').val();
var id = $(this).closest("form").find('input[name=cid]').val();
});
//or
jQuery('body').on('click', '.qupdate', function (){
var form = $(this).closest("form");
var forminput = form.serialize();
});
I am new to Angular and am struggling to add a comment to a specific post that is being displayed from a database.
Under the post I have a hidden comment area that shows when pressing the button.
I then want to be able to add the comment to the post the comment area is attached too.
It seems like it is not getting the id but I can't find how to solve it.
It is doing the show/hide, and I am getting the "data inserted" in the console log so I'm guessing the problem is with the PHP?
Angular code
app.controller('meetings', function($scope, $http) {
$scope.meetings_insertdata = function() {
$http.post ("meetings_insert.php",{'meetings_commentdate':$scope.meetings_commentdate,'meetings_comment':$scope.meetings_comment})
window.location.reload();
console.log("data inserted");
};
});
app.controller('show_hide', function ($scope) {
$scope.Hidden = true;
$scope.ShowHide = function () {
$scope.Hidden = $scope.Hidden ? false : true;
}
});
meetings_insert.php
<?php
$data = json_decode(file_get_contents("php://input"));
$meetings_comment = $data->meetings_comment;
$meetings_commentdate = date('Y-m-d H:i:s');
$meetings_entry = $_GET['id'];
mysql_connect("localhost","user","password");
mysql_select_db("mdb_rh316");
mysql_query("UPDATE project_meetings SET (meetings_comment, meetings_commentdate) = ('$meetings_comment','$meetings_commentdate') WHERE meetings_entry = '$meetings_entry'");
?>
HTML code
<div class="entrybox" ng-controller="meetings">
<?php
mysql_connect("localhost","user","password");
mysql_select_db("mdb_rh316");
$result = mysql_query("SELECT * FROM project_meetings ORDER BY meetings_date DESC");
while ($row = mysql_fetch_array($result))
{
echo "<table>";
echo "<tr><td>" ?>Added: <? echo $row['meetings_date'] . $row['meetings_entry'] . "<br/>" . $row['meetings_content']."</td></tr>";
echo "<tr><td>" ?><br/><span class="emp">Comment: <?
echo $row['meetings_commentdate']."<br/>" . $row['meetings_comment']."</td></tr>";
echo "<tr><td>"?></span>
<div ng-controller="show_hide">
<input type="button" class="previous_add" value="Add comment" ng-click="ShowHide()" />
<br />
<br />
<div ng-hide = "Hidden">
<form method="post" action="meetings_insert.php?id=<? echo $row['$meetings_entry']?>">
<textarea class="textarea" placeholder="Add your comment here.." type="text" ng-model="meetings_comment" name="meetings_comment"></textarea><br/>
<input type="button" class="button" value= "Add" ng-click="meetings_insertdata()"/>
</form>
</div>
</div>
</td></tr><br/><?;
}
echo "</table>";
?>
</div>
Pass 'id' into the meetings_insertdata function:
<form method="post" action="">
<textarea class="textarea" placeholder="Add your comment here.." type="text" ng-model="meetings_comment" name="meetings_comment"></textarea>
<br/>
<input type="button" class="button" value="Add" ng-click="meetings_insertdata(<? echo $row['$meetings_entry']?>)" />
</form>
Receive it in the AngularJS function below:
app.controller('meetings', function($scope, $http) {
$scope.meetings_insertdata = function(id) {
$http.post("meetings_insert.php", {
'meetings_commentdate': $scope.meetings_commentdate,
'meetings_comment': $scope.meetings_comment,
'meetings_event': id
})
window.location.reload();
console.log("data inserted");
};
});
Then, pick up 'id' from the posted value ($data->meetings_event)
$data = json_decode(file_get_contents("php://input"));
$meetings_comment = $data->meetings_comment;
$meetings_commentdate = date('Y-m-d H:i:s');
$meetings_entry = $data->meetings_event;
I need help on this code. I want to dynamically prohibit a user from adding to cart if the requested stock item (Database) is less than his request (qty). Will appreciate, if I can know where I am wrong and probably someone correct it for me.
HTML FORM
<form action="cart.php?adm_id=<?php echo urlencode($patient["adm_id"]);?>" method="post" name="CartForm" target="_self">
<p>Product Name:<select name="prod_name" size="1" id="prod_name">
<option value="Select">Select</option>
<?php
while ($line = mysqli_fetch_array($query, MYSQL_ASSOC)) {
?>
<option value="<?php echo $line['prod_name'];?>"> <?php echo $line['prod_name'];?> </option>
<?php } ?>
</select></p>
<p>Quantity:<input type="number" name="qty" id="qty" size="30" required="required"/></p>
<input name="submit" type="submit" value="Add to Cart" id="btn"/> | <input name="reset" type="reset" value="Cancel" />
Ajax Code:
<script src="javascript/jquery-2.0.3.js">
</script>
<script type="text/javascript">
$(document).ready(function(ex) {
//$('#stock').load('pharmacy_summary.php');
$('#qty').change(function(){
var prod_name = $('#prod_name').val();
var qty= $('#qty').val();
$.ajax({
url: 'confirmStock.php',
data:{prod_name: prod_name, qty: qty},
success: function(e){
if(e == 'true'){
/*if the quantity is greater than the stock*/
alert('stock Item is lower to your request, reduce it');
$('#btn').prop('disabled', true);
}else{
$('#btn').prop('disabled', false);
} }
})});
});
</script>
PHP/MYSQLI Code:(ConfirmStock.php)
<?php require_once("/includes/db_connection.php");?>
<?php require_once("/includes/functions.php");?>
<?php
if(isset($_GET['prod_name'])){
$getProd = $_GET['prod_name'];
$getQty = $_GET['units'];
global $connection;
$val = "SELECT * FROM pharmacy_stock_tab WHERE prod_name='".$getProd."'";
$conf = mysqli_query($connection,$val);
$fetchVal = mysqli_fetch_array($conf);
$stock = $fetchVal['units'];
if($getQty>$stock){
return $stock;
}else{
return $stock;
}
}
?>
You must change the way you send response and the way you handle the response. change the code in ConfirmStock.php
change the return statements in following way
$result = array();
if($getQty>$stock){
$result['success'] = 'true';
$result['stock'] = $stock;
}else{
$result['success'] = 'false';
}
header('Content-Type: application/json');
echo json_encode($result);
die();
In Ajax success method
success: function(response){
if(response.success == 'true'){
/*if the quantity is greater than the stock*/
alert('stock Item is lower to your request, reduce it');
$('#btn').prop('disabled', true);
}else{
$('#btn').prop('disabled', false);
} }
I'm trying to create an dynamic AJAX function using PHP and MySQL but have had little success so far. Its purpose is to update records in a database without refreshing the page or changing to another page.
On the page with the forms I have the following code:
// jQuery
<script type="text/javascript">
<?php
$sql = "SELECT * from pm_schedule";
$result = $pdo->query($sql);
foreach ($result as $row)
{
echo
"$(document).ready(function() {
$('#updatebtn".$row['id']."').click(function() {
$('#result".$row['id']."').show('slow').delay(4000).hide('slow')
$.post('process.php', $('#updateform".$row['id']."').serialize())
});
return false;
});";
}
?>
</script>
// form
$sql = "SELECT * from pm_schedule";
$result = $pdo->query($sql);
foreach ($result as $row)
{
echo
'<form id="updateform'.$row['id'].'">
<div class="tbl_header">'.$row['task'].'</div>
Due Date:
<script>
$(function() {
$( "#datepicker'.$row['id'].'" ).datepicker({ minDate: -0,
dateFormat: \'dd/mm/yy\', maxDate: new Date(2013, 1,22) })
});
</script>
<input type="text" id="datepicker'.$row['id'].'" style="width: 100px; height: 10px;" value="'.$row['duedate'].'" name="duedate"/>
Status:
<select style="width: 125px;" name="status">
<option>'.$row['status'].'</option>
<option>----</option>
<option>Pending</option>
<option>In Progress</option>
<option>Complete</option>
</select>
<input type="hidden" name="id" value="'.$row['id'].'">
<input type="submit" id="updatebtn'.$row['id'].'" value="Update"
style="width: 100px;"/>
</form>
<div id="result'.$row['id'].'" style="display: none; color: red">
Update successful!
</div>
<p>';}
On the page responsible for the processing (process.php), I have the following code:
<?php
$name = mysql_real_escape_string($_POST["name"]);
$status = mysql_real_escape_string($_POST["status"]);
$id = mysql_real_escape_string($_POST["id"]);
$sql = "UPDATE pm_schedule SET name=?, status=?, id=? WHERE id=?";
$q = $conn->prepare($sql);
$q->execute(array($name,$status,$id));
?>
What am I doing wrong?
The return false is in the function called on $(document).ready, not in the click-handler, so I guess this causes the form to submit anyway after finishing the clickhandler. Maybe move the statement one line up:
echo
"$(document).ready(function() {
$('#updatebtn".$row['id']."').click(function() {
$('#result".$row['id']."').show('slow').delay(4000).hide('slow');
$.post('process.php', $('#updateform".$row['id']."').serialize());
return false;
});
});";
As ripa said, a few more ; should be helpful either.
place ; over here
foreach ($result as $row)
{
echo
"$(document).ready(function() {
$('#updatebtn".$row['id']."').click(function() {
$('#result".$row['id']."').show('slow').delay(4000).hide('slow');
$.post('process.php', $('#updateform".$row['id']."').serialize());
});
return false;
});";
}