I have a table where i store the current value, and i have a button that should take the current value and subtract 100 from it and save the new value in the database.
<div class="container">
<div class="row">
<div class="col-md-12">
<p>
<center>
<button onClick="updateHp()">ATTACK</button>
</center>
</p>
</div>
</div>
</div>
here is how i get my data (i echoed it out and its okay)
$result = $conn1 ->query($sql);
$row = $result->fetch_assoc();
$boss_name = $row['name'];
$boss_hp = $row['hp'];
<script>
var newHp =<?php echo $boss_hp;?> - 100;
function updateHp(){
}
</script>
Im a bit clueless how to go about the ajax script, i know i need to make the calcualtion nad pass it over to a update.php but here i where i got stuck.