i retrieved data from mysql table into html page i.e

$query="select * from student";
$result=mysql_query($query)or die(mysql_error());
while($rs=mysql_fetch_array($result))
{
?>
<tr>
      <td align="center"><?php echo $rs['st_id']; ?></td>
<td align="center"><?php echo $rs['name']"; ?></td>
<td align="center">&lt;input type="checkbox" name="check" <?php if($rs['checked']==1){echo "checked"; } ?> /></td>
<td align="center"><a href="delete_student.php?id=<?php echo $rs['st_id'];?>"><img src="images/delete_icon.png" alt="Delete" /></a></td>
<td align="center"><a href="update_student.php?id=<?php echo $rs['st_id'];?>"><img src="images/update.png" alt="Update" /></a></td>
</tr>

this is gives me the output
http://www.freeimagehosting.net/uploads/aff354627f.png

assume that checkbox of id 1 is checked and retrieved from mysql table.
<br /> Now what i want to do is that when i checked the remaing two checkbox into this table and a function is called to ajax which goes to php page and update the value of checked field according to the given id (i.e 2 and 3 in this case). Not refreshing the whole page nor updating the whole record just the value of check box.<br/> i am new to ajax so
any help would be greatly appreciated.

Did you get the answer you were searching for? If not, then please answer the following questions..

1. Do you want the change to be made just to the checkbox or should any changes be made to the Database?
2. I see you have an update button. Are you getting the code to work the way you want it without the AJAX call?

If you already have your question answered, please mark this post "solved".

Thank You.

Member Avatar for diafol

This is a little confusing. Is data in the DB supposed to be altered on checkbox click or only when an user presses the update button?

You have a decision to make, update every single time a single checkbox is changed or update batch fashion with a single update button.

The first is easier to code, but possibly a little heavy on server calls.
The second takes a bit more coding (js) but is reasonably light on the old server calls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.