因此,因为我对 jquery 的经验为零,所以我不知道在提交表单而不重新加载页面时如何运行我的 mysql 脚本?简而言之,单选按钮提交->发送表单->查询而不重新加载
我的脚本:
<form id="myForm" method="get">
<div class="row">
<div class="span4 info1">
<section class="widget">
<img src="../bootstrap/img/thumb/0.jpg" width="auto" height="auto">
<?php if ($selectedBg == '0') {
echo '<h2>Current one</h2>';
} ?>
<input type="radio" name="options[]" value="0" onclick="document.getElementById('myForm').submit();"/>
Choose Background
</section>
</div>
</div>
<?php
$checked = $_GET['options'];
for ($i = 0; $i < count($checked); $i++) {
$sql = 'UPDATE blog_users SET background = '.$checked[$i].' WHERE username=?';
$bg = $db->prepare($sql);
$bg->execute(array($session->username));
}
?>
</form>
所以我的问题是如何在不重新加载页面+运行查询的情况下提交我的表单?