order_idの値を取得するために$ _POSTを使用しましたが、すぐに静かになりませんでした。最初にボタン "Show Food"をクリックするか、下の写真のように任意のボタンを押して、出力したいテーブルをポップアップする必要があります。そして、if(isset($ _ SESSION ['viewOrder']))を使ってorder.phpのボタンの値を取得しようとしましたが、セッションを使用してもordermodalで取得できませんでした。ボタンviewOrderの値を取得するにはどうしたらいいですか?他のページから値を取得する方法
WHERE order_id = $ order_idをWHERE order_id = 724に変更すると、すぐにその数値(724)の値がポップアップしますが、フードテーブルのすべての注文の出力になります。だから私の問題は、特定のorder_idに適切な出力を出力するにはどうすればいいですか?
例私は2 order_id 1とorder_id 2を持っています.1の値はburgerとpizzaで、2の値はsaladとsandwichです。したがって、order_id 1(order.phpのOrderボタンを表示)をクリックすると、その食卓のバーガーとピザだけですし、order_id 2(order.phpのView Orderボタン)をクリックすると、値はサラダとサンドイッチで、ハンバーガーとピザではありません。
私はあなたの説明を理解して、あなたの助けを求める人に願っています。私は本当にこれを直ちに解決する必要があります。私はすでにこの問題のカップルを数日積み重ねていました。本当にあなたの助けをお願いします。本当にありがとう!
This is what I get when clicking a button inside the ordermodal.php
これはorder.phpのための私のコードです。
<button type="button"
<?php if($order['order_status'] == 'Dispatched'){ ?> input style="background-color:#ffff00;color:black"
<?php } else if($order['order_status'] == 'Accepted'){ ?> input style="background-color:#0000ff;color:white" <?php } else if($order['order_status'] == 'Pending'){ ?> input style="background-color:#B0C4DE;color:black" { <?php } ?>
class="btn btn-success" data-toggle="modal" data-target="#myModal" onclick="viewOrder('<?= $order['order_id'] ?>', '<?= $order['order_id'] ?>', '<?= $order['user_id'] ?>', '<?= $date ?>', '<?= $time ?>', '<?= $order['order_deliveryCharge'] ?>', '<?= $order['order_totalAmount'] ?>', '<?= $order['address'] ?>', '<?= $order['coordinates'] ?>', '<?= $order['driver_number'] ?>', '<?= $order['order_status'] ?>')"> View Order </button>
<script>
function viewOrder(order_id, order_id, user_id, order_date, order_time, order_deliveryCharge, order_totalAmount, address, coordinates, driver_number, order_status) {
document.getElementById("titleModal").innerHTML = "Order Information";
document.getElementsByName("ORDER_ID")[0].setAttribute("value", order_id);
document.getElementsByName("ORDER_ID_MODAL_2")[0].setAttribute("value", order_id);
document.getElementsByName("user_id")[0].setAttribute("value", user_id);
document.getElementsByName("order_date")[0].setAttribute("value", order_date);
document.getElementsByName("order_time")[0].setAttribute("value", order_time);
document.getElementsByName("order_deliveryCharge")[0].setAttribute("value", order_deliveryCharge);
document.getElementsByName("order_totalAmount")[0].setAttribute("value", order_totalAmount);
document.getElementsByName("address")[0].setAttribute("value", address);
document.getElementsByName("coordinates")[0].setAttribute("value", coordinates);
document.getElementsByName("drivers_number")[0].setAttribute("value", driver_number);
document.getElementsByName("order_status")[0].setAttribute("value", order_status);
document.getElementsByName("viewOrder")[0].setAttribute("name", "viewOrder");
}
</script>
そして、これはordermodal.php
<div class="form-group">
<label for="order_id" class="col-sm-2 control-label">Order ID</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="ORDER_ID" id="ORDER_ID" placeholder="" value="" required="required" readonly>
</div>
</div>
<?php
if(isset($_POST['ORDER_ID'])){
$order_id = trim(addslashes($_POST['ORDER_ID']));
$sql = "SELECT food_name, special_request, quantity, amount
FROM cart_tbl
WHERE order_id=$order_id";
$result = mysqli_query(connection2(), $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>
</div>
<div class="modal-footer">
<button type="submit" input style="background-color:##FF0000;color:white;float:left" name="showFood" id="showFood" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to see food order?')){return false;}" > Show Food</button>
<button type="submit" input style="background-color:#4CAF50;color:white" name="submitDelivered" id="submitDelivered" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to deliver order?')){return false;}" > Delivered </button>
<button type="submit" input style="background-color:#0000FF;color:white" name="submitAccept" id="submitAccept" class="btn btn-primary" onclick="if(!confirm('Are you sure you want to accept order?')){return false;}"> Accept </button>
<button type="button" style="background-color:#FFFF00;color:black" class="btn btn-success" data-toggle="modal" data-target="#myDropdown"> Send </button>
<button type="submit" input style="background-color:#f44336;color:white" name="submitCancel" class="btn btn-danger" onclick="if(!confirm('Are you sure you want to cancel order?')){return false;}">Cancel</button>
大雑把に言えば、完全なコードとフローの分析が必要なので、この種の質問に答える人はほとんどいないでしょう。私はそれをやろうとしている人ではありません。私はちょうど1つのことに気づいた:なぜあなたは関数のviewOrderでorder_idパラメータの2倍を送信するのですか?そうすることで、渡された値のオフセットが確実に発生します。 –
value属性はdocument.getElementsByName( "ORDER_ID")[0] .setAttribute( "value"、order_id)によって正常に設定されますか。 ? – Cobolt
@BriceCoustillasは大丈夫です。とにかく2 order_idはORDER_ID、もう1つはORDER_ID_MODAL_2です。 – zxczxczxc