亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

データ変更機能の実裝方法

前のセクションで変更ページ edit.php を作成しました。このセクションでは、変更関數(shù)

35.png

を?qū)g裝します。これは、 delete 関數(shù)を使用するには、変更する必要がある情報の ID を取得する必要があります。 SQL ステートメントを通じて、データベース內(nèi)のこの ID のすべての情報をクエリします。次に、SQL ステートメントを使用してこの ID の情報を変更します。

変更関數(shù)を?qū)g裝するための 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 コードに表示します:

ここでは非表示のドメインを使用する必要があります type ="hidden " ID を取得します。

<form> フォームに次のステートメントを追加します:

<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 スタイルは次のとおりです。必要に応じて調(diào)整します:

<div class="form-group">
  <div class="label">
    <label>標題:</label>
  </div>
  <div class="field">
    <input type="text" class="input w50" value="<?php echo $rel["title"]?>" name="title" data-validate="required:請輸入標題" />
    <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>

もちろん、list.php に次の変更を加えます。$rows["id"] には、削除関數(shù)と同じ 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 ファイル內(nèi)の関數(shù)コードを変更し、SQL ステートメントを通じてデータベース內(nèi)のこの ID の情報を変更できます。

rreeee


學び続ける
||
<?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>"; } ?>