I have done that when I push button it should insert data into mysql database but it only inserts it when I reload page. Here Is the code:
<script>
function minuscredits()
{
alert("hah");
<?php
mysql_query("UPDATE `users` SET credits=credits-1 WHERE user_id=".$_SESSION['user']);
?>
}
</script>
When I push button I get alert but not insert into database only if I reload page it inserts successfully.