I need to put a mysql_query
in the onClick
event of a div
. I tried this, but it does not work.
notifiche.php
while ($i < $result) {
$id_noti = mysql_result($res, $i, "id");
$msg=mysql_result($res,$i,"msg");
?>
<div class="box" align="left" style="color: #5c5c5c; padding:4px; border-bottom: 1px solid #c0c0c0; width: 170px !important; position:relative;z-index: auto;">
<div onClick="doSomething();" class="close_box" align="right"style="font-weight:bold; position:absolute;right:0; top:0; z-index:1;cursor:pointer;">
x
<input type="hidden" name="del_noti" value="<?echo $id_noti;?>">
</div>
<? echo $msg; ?>
</div>
<? $i++;
}
the script in the head of main page is
<script type="text/javascript">
function doSomething(){
$.post("del_notif.php");
return false;
}
</script>
and the del_notif.php
include 'files/config.php';
mysql_query("UPDATE notifiche SET a='delete' WHERE id='$_POST[del_noti]'");