我如何调用,insertScore
以便我可以传递值。我认为它看起来像这样。insertScore($name,$num_guess)
但我把它放在哪里?
这是PHP 部分:
function insertScore($name,$num_guess){
opendb();
$query = mysqli_query($GLOBALS['dbconn'],"INSERT INTO game VALUES (0,'$name',$num_guess");
closedb();}
这是Ajax 部分:
$("#user .button ul li #submit").click( function(){
$.post("utilities.php",{
user_name:$("#user_name").val(),
num_guess:$("#num_guess").val()
},
function(response){
$("#msgbox #msg").html("Score Submitted");
$("#msgbox").slideUp().slideDown("slow");
}
);
return false;
});