我的编辑表单没有错误,但我想编辑的数据没有显示。
我尝试在编辑表单中插入新信息,认为信息可能会改变,但什么都没发生。
以下是我的代码。
edit_item.php
<!DOCTYPE HTML>
<?php require('header.php');
?>
<html>
<head>
<title></title>
<!-- css js -->
<?php include "layout/cssjs.php";?>
</head>
<!-- check login session -->
<body class="no-sidebar">
<?php
$id = isset($_GET['id']) ? $_GET['id'] : '';
$nama = isset($_GET['nama']) ? $_GET['nama'] : '';
$noIc = isset($_GET['noIc']) ? $_GET['noIc'] : '';
$gred = isset($_GET['gred']) ? $_GET['gred'] : '';
$unit = isset($_GET['unit']) ? $_GET['unit'] : '';
$catatan = isset($_GET['catatan']) ? $_GET['catatan'] : '';
$status = isset($_GET['status']) ? $_GET['status'] : '';
$sql = mysql_query("SELECT * FROM datastaf WHERE id = '$id'");
$result = mysql_fetch_array($sql);
?>
<div id="page-wrapper">
<!-- Header -->
<!-- Main -->
<article id="main">
<header class="special container">
<h2>Update <strong>Student</strong></h2>
<p>Update Student Details</p>
</header>
<!-- Content -->
<section class="wrapper style4 container">
<!-- Content -->
<div class="content">
<section>
<form method="post">
<div class="row 50%">
<div class="6u 12u(mobile)">
<input type="text" name="id" placeholder="id" value="<?php echo $id; ?>" readonly />
</div>
<div class="6u 12u(mobile)">
<input type="text" name="nama" placeholder="Nama" value="<?php echo $nama; ?>" required />
</div>
</div>
<div class="row 50%">
<div class="6u 12u(mobile)">
<input type="text" name="noIc" placeholder="Noic" value="<?php echo $noIc; ?>" required />
</div>
</div>
<div class="row 50%">
<div class="6u 12u(mobile)">
<input type="text" name="gred" placeholder="Gred" value="<?php echo $gred; ?>" required />
</div>
</div>
<div class="row 50%">
<div class="6u 12u(mobile)">
<input type="text" name="unit" placeholder="Unit" value="<?php echo $unit; ?>" required />
</div>
</div>
<div class="row 50%">
<div class="2u 12u(mobile)">
<input type="text" name="tkuatkuasa" placeholder="TKUATKUASA" value="T/KUATKUASA" readonly />
</div>
<div class="6u 10u(mobile)">
<input type="date" name="catatan" placeholder="dd/mm/yyyy" value="<?php echo $catatan; ?>" required />
</div>
<div class="row">
<div class="12u">
<ul class="buttons">
<li><input type="reset" name="reset" value="Reset" /></li>
<li><input type="submit" name="update" class="special" value="Update" /></li>
</ul>
</div>
</div>
</form>
</section>
</div>
</section>
</article>
</div>
<!-- Scripts -->
<?php include "layout/script.php"; ?>
</body>
</html>
&#13;
的header.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Record Management System</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
<meta name="author" content="Muhammad Usman">
<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
<link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
<link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
<link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
<link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
<link href='css/uploadify.css' rel='stylesheet'>
<link href='css/animate.min.css' rel='stylesheet'>
<!-- jQuery -->
<script src="bower_components/jquery/jquery.min.js"></script>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<?php require ('include/database.php'); ?>
<?php require ('session.php'); ?>
<?php if (!isset($no_visible_elements) || !$no_visible_elements) { ?>
<!-- topbar starts -->
<div class="navbar navbar-default" role="navigation">
<div class="navbar-inner">
<button type="button" class="navbar-toggle pull-left animated flip">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="home.php"> <img alt="Charisma Logo" src="img/logo20.png" class="hidden-xs"/>
<span>ICT MS</span></a>
<!-- user dropdown starts -->
<div class="btn-group pull-right">
<?php
include('include/database.php');
$user_query=mysql_query("select * from user where user_id='$id_session'")or die(mysql_error());
$row=mysql_fetch_array($user_query); {
?>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-user"></i><span class="hidden-sm hidden-xs"> <?php echo $row['username']; ?></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!---<li><a href="#">Profile</a></li>
<li class="divider"></li>-->
<li><a href="logout.php"><i class="glyphicon glyphicon-off"></i> Logout</a></li>
</ul>
</div>
<?php } ?> <!-- user dropdown ends -->
<div class="btn-group pull-right theme-container animated tada">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-tint"></i><span
class="hidden-sm hidden-xs"> Change Theme / Skin</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="themes">
<li><a data-value="classic" href="#"><i class="whitespace"></i> Classic</a></li>
<li><a data-value="cerulean" href="#"><i class="whitespace"></i> Cerulean</a></li>
<li><a data-value="cyborg" href="#"><i class="whitespace"></i> Cyborg</a></li>
<li><a data-value="simplex" href="#"><i class="whitespace"></i> Simplex</a></li>
<li><a data-value="darkly" href="#"><i class="whitespace"></i> Darkly</a></li>
<li><a data-value="lumen" href="#"><i class="whitespace"></i> Lumen</a></li>
<li><a data-value="slate" href="#"><i class="whitespace"></i> Slate</a></li>
<li><a data-value="spacelab" href="#"><i class="whitespace"></i> Spacelab</a></li>
<li><a data-value="united" href="#"><i class="whitespace"></i> United</a></li>
</ul>
</div>
<ul class="collapse navbar-collapse nav navbar-nav top-menu">
<li><a href="#"><i class="glyphicon glyphicon-globe"></i> Visit Site</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="glyphicon glyphicon-star"></i> Dropdown <span
class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
<li class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<li>
<form class="navbar-search pull-left">
<input placeholder="Search" class="search-query form-control col-md-10" name="query"
type="text">
</form>
</li>
</ul>
</div>
</div>
<!-- topbar ends -->
<?php } ?>
<div class="ch-container">
<div class="row">
<?php if (!isset($no_visible_elements) || !$no_visible_elements) { ?>
<!-- left menu starts -->
<div class="col-sm-2 col-lg-2">
<div class="sidebar-nav">
<div class="nav-canvas">
<div class="nav-sm nav nav-stacked">
</div>
<ul class="nav nav-pills nav-stacked main-menu">
<li class="nav-header">Main</li>
<li><a class="ajax-link" href="home.php"><i class="glyphicon glyphicon-home"></i><span> Home</span></a></li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span> Masterfile</span></a>
<ul class="nav nav-pills nav-stacked">
<li><a class="ajax-link" href="item.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Data Staf</span></a></li>
<li><a class="ajax-link" href="addStaf.php"><i class="glyphicon glyphicon-chevron-right"></i><span> + Staf Baru</span></a></li>
<li><a class="ajax-link" href="unit.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Unit</span></a></li>
<li><a class="ajax-link" href="contact.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Contact</span></a></li>
<li><a class="ajax-link" href="user.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Admin Account</span></a></li>
</ul>
</li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span> Transaction</span></a>
<ul class="nav nav-pills nav-stacked">
<li><a class="ajax-link" href="release.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Releasing</span></a></li>
<li><a class="ajax-link" href="return.php"><i class="glyphicon glyphicon-chevron-right"></i><span> Returning</span></a></li>
</ul>
</li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-th-list"></i><span> Record</span></a>
<ul class="nav nav-pills nav-stacked">
<li><a class="ajax-link" href="list_of_item.php"><i class=" glyphicon glyphicon-chevron-right"></i><span> List of Item</span></a></li>
<li><a class="ajax-link" href="list_of_client.php"><i class=" glyphicon glyphicon-chevron-right"></i><span> List of CLient</span></a></li>
<li><a class="ajax-link" href="list_of_transaction.php"><i class=" glyphicon glyphicon-chevron-right"></i><span> List of Transaction</span></a></li>
</ul>
</li>
<li><a class="ajax-link" href="history.php"><i class="glyphicon glyphicon-bookmark"></i><span> History Log</span></a></li>
<li><a class="ajax-link" href="ui.php"><i class="glyphicon glyphicon-eye-open"></i><span> UI Features</span></a>
</li>
<li><a class="ajax-link" href="form.php"><i
class="glyphicon glyphicon-edit"></i><span> Forms</span></a></li>
<li><a class="ajax-link" href="chart.php"><i class="glyphicon glyphicon-list-alt"></i><span> Charts</span></a>
</li>
<li><a class="ajax-link" href="typography.php"><i class="glyphicon glyphicon-font"></i><span> Typography</span></a>
</li>
<li><a class="ajax-link" href="gallery.php"><i class="glyphicon glyphicon-picture"></i><span> Gallery</span></a>
</li>
<li class="nav-header hidden-md">Transaction</li>
<li><a class="ajax-link" href="table.php"><i
class="glyphicon glyphicon-align-justify"></i><span> Tables</span></a></li>
<li class="accordion">
<a href="#"><i class="glyphicon glyphicon-plus"></i><span> Accordion Menu</span></a>
<ul class="nav nav-pills nav-stacked">
<li><a href="#">Child Menu 1</a></li>
<li><a href="#">Child Menu 2</a></li>
</ul>
</li>
<li><a class="ajax-link" href="calendar.php"><i class="glyphicon glyphicon-calendar"></i><span> Calendar</span></a>
</li>
<li><a class="ajax-link" href="grid.php"><i
class="glyphicon glyphicon-th"></i><span> Grid</span></a></li>
<li><a href="tour.php"><i class="glyphicon glyphicon-globe"></i><span> Tour</span></a></li>
<li><a class="ajax-link" href="icon.php"><i
class="glyphicon glyphicon-star"></i><span> Icons</span></a></li>
<li><a href="error.php"><i class="glyphicon glyphicon-ban-circle"></i><span> Error Page</span></a>
</li>
<li><a href="login.php"><i class="glyphicon glyphicon-lock"></i><span> Login Page</span></a>
</li>
</ul>
<label id="for-is-ajax" for="is-ajax"><input id="is-ajax" type="checkbox"> Ajax on menu</label>
</div>
</div>
</div>
<!--/span-->
<!-- left menu ends -->
<!-- <noscript>
<div class="alert alert-block col-md-12">
<h4 class="alert-heading">Warning!</h4>
<p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
enabled to use this site.</p>
</div>
</noscript>-->
<div id="content" class="col-lg-10 col-sm-10">
<!-- content starts -->
<?php } ?>
&#13;
我的数据库表datastaf
如下所示:
我在这些链接上找不到答案:
答案 0 :(得分:1)
乍一看,您正在使用方法发布并尝试使用GET检索数据,请改用$ _POST
e.g。
$id = isset($_POST['id']) ? $_POST['id'] : '';
答案 1 :(得分:0)
首先确保您获取数据。
例如: $ _GET ['nama']应该具有您正在寻找的价值 $ nama = isset($ _ GET ['nama'])? $ _GET ['nama']:'';
你可以使用die($ _ GET ['nama']);并检查你是否得到了这个价值。
答案 2 :(得分:0)
假设您已建立连接,我做了一些更改 随意调整它。
<?php
include('db.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['update']))
{
$nama=$_POST[''];
$noIc=$_POST['noIc'];
$gred=$_POST['gred'];
$unit=$_POST['unit'];
$catatan= $_POST ['catatan'];
$status= $_POST ['status']
$updated=mysql_query("UPDATE datastaf SET unama='$nama', noIc='$noIc', gred='$gred', unit= '$unit', catatan='$catatan', status='$status' WHERE id='$id'")
or die();
if($updated)
{
$msg="Successfully Updated!!";
header('Location:item.php');
}
}
}
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit form</title>
<link type="text/css" media="all" rel="stylesheet" href="style.css">
</head>
<body>
<?php
if(isset($_GET['id']))
{
$id=$_GET['id'];
$getselect=mysql_query("SELECT * FROM datastaff WHERE id='$id'");
while($profile=mysql_fetch_array($getselect))
{
$nama=$profile['nama'];
$noIc=$profile['noIc'];
$gred=$profile['gred'];
$unit=$profile['unit'];
$catatan=$profile['catatan'];
$status=$profile['status'];
?>
<div class="display">
<form action="" method="post" name="insertform">
<p>
<label for="name" id="preinput"> NAMA : </label>
<input type="text" name="nama" required placeholder="Nama"
value="<?php echo $nama; ?>" id="inputid" />
</p>
<p>
<label for="noIc" id="preinput"> NO IC : </label>
<input type="number" name="noIc" required placeholder="NO IC"
value="<?php echo $noIc; ?>" id="inputid" />
</p>
<p>
<label for="gred" id="preinput"> GRED : </label>
<input type="text" name="gred" required placeholder="Gred"
value="<?php echo $gred; ?>" id="inputid" />
</p>
<p>
<label for="gred" id="preinput"> UNIT: </label>
<input type="text" name="unit" required placeholder="UNIT"
value="<?php echo $unit; ?>" id="inputid" />
</p>
<p>
<label for="gred" id="preinput"> CATATAN : </label>
<input type="text" name="gred" required placeholder="CATATAN"
value="<?php echo $catatan; ?>" id="inputid" />
</p>
<p>
<label for="gred" id="preinput"> STATUS : </label>
<input type="text" name="status" required placeholder="STATUS"
value="<?php echo $status; ?>" id="inputid" />
</p>
<p>
<input type="submit" name="update" value="Update" id="inputid1" />
</p>
</form>
</div>
<?php } } ?>
</body>
</html>