`I have a web page where testimonials are displayed. I want to display only those testimonials whose "status" is "1" in the database. How do I update my database column named "status" from "0" to "1" straight away after the admin click on update . I am using AJAX also.
<tr align='center'>
<?php
include ('includes/connect.php');
$query1= "SELECT* from testdata ORDER BY 1 DESC ";
$run= mysql_query($query1) ;
while
($row =mysql_fetch_array($run)){
$Id=$row['0'];
$name=$row['1'];
$company=$row['2'];
$designation=$row['3'];
$email= $row['4'];
$message=$row['5'];
?>
<td> <?php echo $Id?> </td>
<td> <?php echo $name; ?> </td>
<td> <?php echo $company ?> </td>
<td> <?php echo $designation ?> </td>
<td> <?php echo $email ?> </td>
<td> <?php echo $message ?> </td>
<td > <form method ="post" action= "update.php"> <input type ="submit" value= "approve" name ="approve"></input></form> </td>
</tr>
<?php } ?>
<tr align='center'>
<td> <?php echo $Id?> </td>
<td> <?php echo $name1; ?> </td>
<td> <?php echo $company1 ?> </td>
<td> <?php echo $designation1 ?> </td>
<td> <?php echo $email1 ?> </td>
<td> <?php echo $message1 ?> </td>
<td > <input class='action' type ="submit" value= "update" name ="update"></input> </td>
</tr>
just change your query
"select * from testdata where status =".$_POST['data1'] "
and in your script change the $(this).attr('id') to $(this).val()
$('#approve').change(function(){
var data1 = $(this).val();
$.ajax({ / / ajax block starts
url: 'update.php', //
type: 'POST',
data: {
data1: data1
},
success: function(data) {
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.