我正在尝试使用 jquery 发布数据以进行插入,但无法这样做,变量正在正确获取值,但我不认为 php 页面在那之后可以正常工作,我认为 php 页面没有任何错误。这是我的代码
<script>
function print_this(){
var nit =$('#a').val();
var reg = $('#b').val();
var c = $('#csa').val();
var d = $('#dc').val();
var e = $('#Ee').val();
var f = $('#Er').val();
var w = $('#w').val();
var h = $('#w').val();
var i = $('#i').val();
PostValue(a,b,c,d,e,f,w,h,i)}
function PostValue(a,b,c,d,e,f,w,h,i){
$.ajax({
type: "POST",
url: "print.php",
data: {a:a,b:b,c:c,d:d,e:e,f:f,w:w,h:h,i:i},
success:function(data){
$("#print").printThis();
}
})
}
这是我的php页面
$conn = mysql_connect('localhost','','') or die ("Connection Problem");
mysql_select_db("") or die ("Database Problem");
function print_this(){
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
$d = $_POST['d'];
$query = "select * from print where a = $a and b = $b and c = $c and d = $d";
$result = mysql_query($query);
if(mysql_num_rows($result) == 0)
{
$query = "INSERT INTO print (id ,a,b,c,d,e,f,w,h,i) VAUES
(NULL, '".$_POST['a']."','".$_POST['b']."','".$_POST['c']."','".$_POST['d']."','".$_POST['e']."','".$_POST['f']."','".$_POST['w']."','".$_POST['h']."','".$_POST['i']."')";
$result = mysql_query($query) or die();}