-2
我已經創建了一個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();
}
任何建議將不勝感激。
想要更具體嗎? – user1852050
支架位於代碼下方。縮進代碼時我錯過了它。我也加倍檢查了我的文件,所有的大括號都佔了。 – user1852050