我正在嘗試完成我的新個人CMS(內容管理系統),並且我已經編寫了一個部分,其中包括使用PHP,MySql和bootstrap Modal插入,選擇和刪除項目。 顯然我有更新查詢的麻煩。該過程是當我點擊編輯按鈕,模態Bootstrap將顯示,然後關聯數據將通過值屬性檢索表單Mysql。比我改變他們後點擊提交按鈕。問題在這裏!當過程完成時,我的$ _POST ['input_result']會出現錯誤。 var_dump獲得NULL,最後我有未定義的索引。 有沒有人找出這個問題?謝謝你們。 這裏是我的模式引導代碼PHP:使用模式Bootstrap更新查詢獲取未定義索引
<?php
$selectForUpdate = "SELECT * FROM ring WHERE id='4'";
$resultSelectForUpdate = mysqli_query($connect_to_db, $selectForUpdate);
$first = $second = $third= '';
$first = $_POST['u_ringCode'];
$second = $_POST['u_ringWeight'];
$third = $_POST['u_ringComment'];
$updateQuery = "UPDATE ring SET ring_code='".$first."', ring_weight='".$second."', ring_comment='".$third."' WHERE id='4'";
$resultUpdateQuery = mysqli_query($connect_to_db, $updateQuery);
while ($showUpdateRows = mysqli_fetch_assoc($resultSelectForUpdate)) {
?>
<!-- Update Modal -->
<div class="modal fade bs-example-modal-sm" id="update-4" tabindex="-1" role="dialog" aria-labelledby="update-4-label" >
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h5 class="modal-title text-center" id="update-4-label" style="color:#ddd;" >
Edit Code
</h5>
</div>
<div class="modal-body">
<div class="col-md-12 col-sm-12 col-xs-12">
<form method="post" action="<?=htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<label for="">Ring Code :</label>
<input type="text" class="form-control" id="" name="u_ringCode" placeholder="" value="<?=$showUpdateRows['ring_code']?>">
</div>
<div class="form-group">
<label for="">Ring Weight :</label>
<input type="text" class="form-control" id="" name="u_ringWeight" placeholder="" value="<?=$showUpdateRows['ring_weight']?>">
</div>
<div class="form-group">
<label for="">Comment :</label>
<input type="text" class="form-control" id="" name="u_ringComment" placeholder="" value="<?=$showUpdateRows['ring_comment']?>">
</div>
</form>
</div>
</div>
<div class="modal-footer">
<a type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
<a type="submit" class="btn btn-default pull-left" name="ringDelete" style="color:black;" href="?update=4">Submit</a>
</div>
</div>
</div>
</div>
<?php
}
?>
你爲什麼不使用提交按鈕 –