我很抱歉,但是在编辑我的数据时遇到了一些困难,问题是当我点击按钮编辑时,它可以正常工作但是当你回到上一页时,它就像是没有库存了所以数组保持这个特定id的未知数。
这是代码:
<?php
include_once 'dbconfig.php';
$id = $_GET['quotauser'];
if (isset($id)) {
extract($crud->getQUOTA($id));
}
include_once 'headerQ.php';
?>
<div class="clearfix"></div>
<div class="container">
<a href="add-quota.php?add-quota" class="btn btn-large btn-info">
<i class="glyphicon glyphicon-plus"></i> Add Quota
</a>
</div>
<div class="clearfix"></div><br />
<div class="container">
<table class='table table-bordered table-responsive'>
<tr>
<th>id</th>
<th>QTANAME</th>
<th>SRVNAME</th>
<th>QTAVALUE</th>
<th colspan="3" align="center">Actions</th>
</tr>
<?php
$query = "SELECT quota.* FROM quota,user WHERE user.id=quota.id_user AND quota.id_user= '.$id.' ";
$records_per_page = 10;
$newquery = $crud->paging($query, $records_per_page);
$crud->quotaID($newquery);
?>
<tr>
<td colspan="10" align="center">
<div class="pagination-wrap">
<?php $crud->paginglink($query, $records_per_page); ?>
</div>
</td>
</tr>
</table>
</div>
<?php include_once 'footer.php'; ?>
单击按钮显示配额时,包含配额的页面包含两个选项编辑和删除
并且编辑按钮将您带到此页面
编辑的代码是:
<?php
include_once 'dbconfig.php';
if (isset($_POST['btn-update'])) {
$id = $_GET['edit_quota'];
$QTANAME = $_POST['QTANAME'];
$SRVNAME = $_POST['SRVNAME'];
$QTAVALUE = $_POST['QTAVALUE'];
if ($crud->updateQ($id, $QTANAME, $SRVNAME, $QTAVALUE)) {
$msg = "<div class='alert alert-info'>
<strong>WOW!</strong> Quota was updated successfully <a href='UserQuota.php'>HOME</a>!
</div>";
} else {
$msg = "<div class='alert alert-warning'>
<strong>SORRY!</strong> ERROR while updating Quota !
</div>";
}
}
if (isset($_GET['edit_quota'])) {
$id = $_GET['edit_quota'];
extract($crud->getQUOTA($id));
}
?>
<?php include_once 'headerQ.php'; ?>
<div class="clearfix"></div>
<div class="container">
<?php
if (isset($msg)) {
echo $msg;
}
?>
</div>
<div class="clearfix"></div><br />
<div class="container">
<form method='post'>
<table class='table table-bordered'>
<tr>
<td>QTANAME</td>
<td><input type='text' name='QTANAME' class='form-control' value="<?php echo $QTANAME; ?>" required></td>
</tr>
<tr>
<td>SRVNAME</td>
<td><input type='text' name='SRVNAME' class='form-control' value="<?php echo $SRVNAME; ?>" required></td>
</tr>
<tr>
<td>QTAVALUE</td>
<td><input type='number' name='QTAVALUE' class='form-control' value="<?php echo $QTAVALUE; ?>" required></td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-primary" name="btn-update">
<span class="glyphicon glyphicon-edit"></span> Update this Record
</button>
<a href="UserQuota.php" class="btn btn-large btn-success"><i class="glyphicon glyphicon-backward"></i> CANCEL</a>
</td>
</tr>
</table>
</form>
</div>
<?php include_once 'footer.php'; ?>