<?php header("Content-type: text/html; charset=utf-8");//设置统一输出编码为utf-8 $building = $_POST['building']; $week = $_POST['week']; $startTime = $_POST['startTime']; $endTime = $_POST['endTime']; $conn=newmysqli("localhost","root","","rucHelper"); //数据库连接 if ($conn->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } $conn->query("SET NAMES utf8"); //设置读取数据后的编码 //var_dump($conn); $stmt=$conn->prepare('SELECT distinct classroom FROM allcourse WHERE building =? and classroom not in (SELECT distinct classroom FROM allcourse where building =? and week =? and (startTime >=? and startTime<=? or endTime >=? and endTime <=?) ) order by classroom'); $stmt->bind_param("ssddddd",$building,$building,$week,$startTime,$endTime,$startTime,$endTime);//参数化查询 $stmt->execute();