我创建了一个接受用户输入并返回相关发票的 html 表单。我没有收到任何错误,并且我检查了我的 html 代码以确保 isset 的条件正确。我还在 PHPAdmin 中测试了查询(它返回我要求的信息)。但是,发票没有打印到屏幕上,错误或 PHP 代码也没有。我在屏幕上看到的唯一内容是标题(未显示 html)和超链接(未显示 html)。下面是相关的 PHP 代码部分。提前致谢。
if( isset($_POST["submit"] )) {
if (!($stmt =$mysqli->prepare("SELECT DISTINCT INVOICE.date, CUSTOMER.Name, CUSTOMER.Lname, CUSTOMER.Phone, CUSTOMER.Address, CUSTOMER.email, INVOICE.Invoice_num, INVOICE.Itm_num, INVOICE.Itm_Price, INVOICE.Discount, INVOICE.Total
FROM CUSTOMER, INVOICE
WHERE CUSTOMER.Phone = INVOICE.Cust_phone AND CUSTOMER.Lname = INVOICE.Cust_lname AND
(CUSTOMER.Name = ? OR CUSTOMER.Lname = ? OR INVOICE.date = ? OR INVOICE.Invoice_num = ? OR INVOICE.Itm_num = ?)
GROUP BY date;"))) {
print "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->bind_param("sssis",$_POST['fname'], $_POST['lname'], $_POST['date'], $_POST['invoice_num'], $_POST['item_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($date, $Fname, $Lname, $Phone, $Address, $Email, $Invoice_num, $Item_num, $Itm_Price, $Discount,$Total)) {
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['date'].$_POST['invoice_num'].$_POST['item_num']."</p>";
}
else {
print "<table border=2 cellpadding=4>
<tr bgcolor=white>
<th>Date</th>
<th>First Name</th>
<th>Last Name</th>
<th>Phone</th>
<th>Address</th>
<th>Email</th>
<th>Invoice #</th>
<th>Item #</th>
<th>Price</th>
<th>Discount (if applicable)</th>
<th>Total</th>
</tr>";
while ($stmt->fetch()) {
print "<tr><td>".$date."</td>
<td>".$Fname."</td>
<td>".$Lname."</td>
<td>".$Phone."</td>
<td>".$Address."</td>
<td>".$Email."</td>
<td>".$Invoice_num."</td>
<td>".$Itm_num."</td>
<td>".$Itm_Price."</td>
<td>".$Discount."</td>
<td>".$Total."</td></tr>";
}
print "</table>";
}
$stmt->free_result();
}
任何建议将不胜感激。