??? ?? ?? ?? ??
?? ???? ?? ??? edit.php? ??????. ? ????? ?? ??
?? ??? ???? ??? ??? ID? ???? ???. ??? SQL ?? ?? ?? ??????? ?? ? ID? ?? ?? ?????. ?? ?? SQL ?? ?? ? ID? ??? ?????
update.php ??? ???? ?? ??? ?????.
edit.php ???? ???? ?????
<?php $id = isset($_GET["id"])?$_GET["id"]:""; $title = isset($_POST['title'])?$_POST['title']:""; $name = isset($_POST['name'])?$_POST['name']:""; $video = isset($_POST['video'])?$_POST['video']:""; $sql = "select id,title,name,video from list where id = '$id'"; $result = mysqli_query($link,$sql); $rel = mysqli_fetch_array($result); ?>
html ??? ?????.
ID? ???? ???? ??? ?? type="hidden"? ???? ???.
<??> ??? ?? ?? ?????.
<form method="post" class="form-x" action="update.php" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $rel["id"]?>"> </form>
??, ??? ??? ?? ? ??? ??? ?? ?????. CSS ???? ??? ?? ??? ? ????.
<div class="form-group"> <div class="label"> <label>標(biāo)題:</label> </div> <div class="field"> <input type="text" class="input w50" value="<?php echo $rel["title"]?>" name="title" data-validate="required:請輸入標(biāo)題" /> <div class="tips"></div> </div> </div>
<div class="form-group"> <div class="label"> <label>視頻:</label> </div> <div class="field"> <input type="text" class="input w50" value="<?php echo $rel["video"]?>" name="video" data-validate="required:請輸入視頻名稱" /> <input type="submit" name="upload" class="button bg-blue margin-left" id="image1" value="+ 瀏覽上傳" style="float:left;"> <div class="tips"></div> </div> </div>
<div class="form-group"> <div class="label"> <label>描述:</label> </div> <div class="field"> <textarea class="input" name="name" style=" width:400px;height:200px;"><?php echo $rel["name"]?></textarea> <div class="tips"></div> </div> </div>
?? ??? ????. .php ??? ?? ??????. $rows["id"] ? ?? ??? ??? while ?? ??? ????.
<div class="button-group"> <a class="button border-main" href="edit.php?id=<?php echo $rows["id"]?>"><span class="icon-edit"></span>修 改</a> <a class="button border-red" href="delete.php?id=<?php echo $rows["id"]?>" onclick="return del(1,1,1)"> <span class="icon-trash-o"></span>刪 除 </a> </div>
?? ???? update.php ??? ?? ??? ????, SQL ?? ?? ???????? ? ID? ??? ??? ? ????.
<?php header("content-type:text/html;charset=utf-8"); include("config.php"); //引入數(shù)據(jù)庫公共文件 $id = isset($_POST["id"])?$_POST["id"]:""; $title = isset($_POST['title'])?$_POST['title']:""; $name = isset($_POST['name'])?$_POST['name']:""; $video = isset($_POST['video'])?$_POST['video']:""; $sql="update list set title='$title',name='$name',video='$video' where id='$id'"; //echo $sql; $rel=mysqli_query($link,$sql);//執(zhí)行sql語句 //echo $rel if($rel){ echo "<script>alert('修改成功');window.location.href='list.php'</script>"; }else{ echo "<script>alert('修改失敗');window.location.href='edit.php'</script>"; } ?>