I want to execute a query during onload. How do I this?
This is my code.
This is the query I want to execute.
<?php
mysql_query("UPDATE `requests` SET `stat_id`= 3 WHERE `proj_id`='".$_GET['projid']."' and DATE(`req_date`)='".$_GET['date']."'");
?>
and I have a javascript
<script type="text/javascript">
$(document).ready(function(){
$('input#approve').click(function(){
var date = $(this).parent().attr('id');
var projid = $(this).parent().attr('class');
window.location.href="index.php?page=requests&date="+date+"&projid="+projid+"";
});
});
</script>
when the button approve is clicked the page is refreshed, but the query is not executing.
You can use the following code in
index.phpfor updating tableCheck w3Schools
Then use ajax to call this page
jQuery ajax reference