我有一个 html 文件,它创建了一个链接到 php 文件的表单,并允许对数据库进行多参数搜索。无论出于何种原因,该文件没有被读取并且我遇到了一个错误,这使得我很难测试我的 sql 查询并验证它是否有效。提前致谢。
这是代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Bicycle Store Employees</title>
<link rel="stylesheet" type="text/css" href="web.css" />
</head>
<body>
<h1>Bicycle Store Manager</h1>
<h2>Customized Business Management for Bicycle Stores</h2>
<h3>EMPLOYEE INFORMATION</h3>
<?php
ini_set('display_errors', 'On');
$mysqli = new mysqli("$database", "$username", "$password", "$username");
if ($mysqli->connect_errno) {
print "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if( $_POST["submit"] ) {
if (!($stmt =$mysqli->prepare("SELECT * into tempTable FROM
(SELECT Fname, Minit, Lname, Address, Hourly, Sname, Saddress, Dno
FROM EMPLOYEE
join on Employee.Dno = DEPARTMENT.Dnumber
join on LOCATION.Store_num = DEPARTMENT.Store_num
where Fname = $_POST['Fname'] OR Lname = $_POST['Lname']
OR Stor_num = $_POST['Store_num'] OR Dno = $_POST['Dno']
GROUP BY Store_num);"))) {
print "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("ssii",$_POST['Fname'], $_POST['Lname'], $_POST['Dno'], $_POST['Store_num'])) {
print "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if (!$stmt->execute()) {
print "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
$stmt->store_result();
if (!$stmt->bind_result($Fname,$Minit,$Lname,$Phone,$Address,$Slocation,$Saddress,$Dno,$Hourly)) {
print "Binding output parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
if ($stmt->num_rows == 0){
print "No results were found for the following search <p>"
.$_POST['Fname'].$_POST['Lname'].$_POST ['Store_num'].$_POST['Dno']."</p>";
}
else {
print "<table border=2 cellpadding=4>
<tr bgcolor=white>
<th>First Name</th>
<th>Middle Initial</th>
<th>Last Name</th>
<th>Phone</th>
<th>Address</th>
<th>Store</th>
<th>Store Location</th>
<th>Dept #</th>
<th>Hourly Rate</th>
</tr>";
while ($stmt->fetch()){
print "<tr><td>".$Fname."</td><td>".$Minit."</td><td>".$Lname.
"</td><td>".$Phone."</td><td>".$Address."</td><td>".$Slocation."</td>
<td>".$Saddress."</td><td>".$Dno."</td><td>".$Hourly."</td></tr>";
}
print "</table>";
}
$stmt->free_result();
}
$mysqli->close();
?>
<p><a href="employee_info.html">SEARCH AGAIN</a></p>
<p><a href="index.html">HOME</a></p>
</body>
</html>