我在自举模式窗体上显示数据时遇到问题。我可以看到屏幕上的数据,一切都很好,但当我点击更新按钮编辑其中一个字段时,模态打开并且没有数据显示,所以当我点击保存它然后将空白字段存储到数据库。
我试图展示的价值观之一是:
value="<?php echo clean($row['clientTown']); ?>"
如果我把它放在除模态之外的页面上的任何位置,它会显示数据。
感谢任何帮助,代码如下。
模态代码
<!-- -- Update Media Info Modal -- -->
<div class="modal fade" id="mediainfo" tabindex="-1" role="dialog" aria-labelledby="personalInfoLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modal-primary">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i></button>
<h4 class="modal-title">Update Media Details</h4>
</div>
<form action="" method="post">
<div class="modal-body">
<div class="form-group">
<label for="clientArea">Hotel Area</label>
<select name="clientArea" id="clientArea" class="form-control">
<?php include 'snippets/countries.php'; ?>
</select>
</div>
<hr>
<div class="form-group">
<label for="clientMailshot">Mailshot Date</label>
<input type="date" class="form-control" name="clientMailshot" id="clientMailshot" value="<?php echo clean($row['clientMailshot']); ?>">
</div>
<div class="form-group">
<label for="clientChase">Chase Date</label>
<input type="date" class="form-control" name="clientChase" id="clientChase" value="<?php echo clean($row['clientChase']); ?>">
</div>
<div class="form-group">
<label for="clientChased">Second Chase Date</label>
<input type="date" class="form-control" name="clientChased" id="clientChased" value="<?php echo clean($row['clientChased']); ?>">
</div>
<div class="form-group">
<label for="clientAppointment">Appointment Date</label>
<input type="date" class="form-control" name="clientAppointment" id="clientAppointment" value="<?php echo clean($row['clientAppointment']); ?>">
</div>
<hr>
<div class="form-group">
<label for="clientBuyer">Media Buyer </label>
<input type="text" class="form-control" name="clientBuyer" id="clientBuyer" value="<?php echo clean($row['clientBuyer']); ?>" />
</div>
</div>
<div class="modal-footer">
<button type="input" name="submit" value="updatemediaInfo" class="btn btn-success btn-icon"><i class="icon-check"></i> Update Info</button>
<button type="button" class="btn btn-warning btn-icon" data-dismiss="modal"><i class="icon-remove-sign"></i> Cancel</button>
</div>
</form>
</div>
</div>
添加到数据库
if (isset($_POST['submit']) && $_POST['submit'] == 'updatemediaInfo') {
if($_POST['clientMailshot'] == "") {
$msgBox = alertBox("Mail Shot is a Required Field.", "<i class='icon-remove-sign'></i>", "danger");
} else {
$clientBuyer = encryptIt($_POST['clientBuyer']);
$stmt = $mysqli->prepare("
UPDATE
clients
SET
clientBuyer = ?,
clientArea = ?,
clientMailshot = ?,
clientChase = ?,
clientChased = ?,
clientAppointment = ?
WHERE
clientId = ?
");
$stmt->bind_param('sssssss',
$mysqli->real_escape_string($_POST['clientBuyer']),
$mysqli->real_escape_string($_POST['clientArea']),
$mysqli->real_escape_string($_POST['clientMailshot']),
$mysqli->real_escape_string($_POST['clientChase']),
$mysqli->real_escape_string($_POST['clientChased']),
$mysqli->real_escape_string($_POST['clientAppointment']),
$clientId
);
$stmt->execute();
$msgBox = alertBox("The Client's Personal Info has been updated.", "<i class='icon-check-sign'></i>", "success");
$stmt->close();
}
}
答案 0 :(得分:1)
没有按钮类型=“输入”这样的东西。将其更改为按钮类型=“提交”
<button type="submit" name="submit" value="updatemediaInfo" class="btn btn-success btn-icon"><i class="icon-check"></i> Update Info</button>