HTML
<input id="box1" type="submit">
$('#box1').click( function() {
$.ajax({
url:"insert.php",
type:"POST",
});
});
PHP insert.php
$link = mysqli_connect("localhost", "root", "", "votingcount");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// attempt update query execution
$sql = "UPDATE vote_result SET vote_count = vote_count + 1 WHERE photo_no=1";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
When the submit button (#box1) is clicked, the UPDATE statement would increase the vote count in SQL by 1. After running the insert.php, at the same time a overlay would appear to show the CURRENT vote count from the SQL, I would want the overlay box content to display the int vote count with the following sql statement : $sql = "SELECT vote_count FROM vote_result WHERE photo_no=1";
How would I allow the .click function for #box1 be able to run another php where I could retrieve the value and update the #clicked value in the following overlay?
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<img src="tyedit.jpg" height="1024" width="724" />
<div id="imagine">
<span id="clicked">0</span><br/>
<span id="word">VOTES</span>
</div>
</div>
</div>