-1
即時通訊新的php和sql現在,所以我混淆了什麼是錯誤的代碼(需要做)cart_tbl(order_id)food_name,special_request,數量,金額等於我的order_id order_tbl。當我的order_tbl和cart_tbl的order_id都相同時。我的輸出將是該表的值。這是我現在的代碼。如何從db中選擇一個值
<?php
$connect = mysqli_connect ("localhost", "root", "" , "db");
if(isset($_POST['order_id'])){
$asd = ($_POST['order_id']);
$sql = "SELECT food_name, special_request, quantity, amount
FROM cart_tbl
WHERE order_id='$asd'";
$result = mysqli_query($connect, $sql);
}
?>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>Food</th>
<th>Special Request</th>
<th>Quantity</th>
<th>Amount</th>
</tr>
</thead>
<?php
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row["food_name"];?></td>
<td><?php echo $row["special_request"];?></td>
<td><?php echo $row["quantity"];?></td>
<td><?php echo $row["amount"];?></td>
</tr>
<?php
}
}
?>
</table>
我得到錯誤「未定義的變量:結果」我不能得到我的文本框的值。下面是我的代碼<?php $ connect = mysqli_connect(「localhost」,「root」,「」,「db」); ($ set($ _ POST ['order_id'])){ \t $ order_id = $ _POST [「order_id」]; $ sql =「SELECT food_name,special_request,quantity,amount FROM cart_tbl WHERE order_id ='$ order_id'」; $ result = mysqli_query($ connect,$ sql); } ?> – Blank
@Blank *「未定義的變量:結果」我無法獲得我的文本框的值。*,這是一個非常不同的問題,而不是你在問題中提出的問題。確保輸入元素中的'name'屬性正確。另外,請執行'var_dump($ _ POST);'並確保鍵和相應的值是正確的。順便說一句,你在哪條線* Undefined變量:結果*錯誤? –
我使用會話,但我不能得到order_id的文本框的值。 BTW它在if(mysqli_num_rows($ result)> 0)線我想。 – Blank