:::

7-3 上課範例:save_class.php

<?php
error_reporting(0);
$link=@mysql_connect("localhost" , "tad0616" ,"12345");

if(!$link)  echo "資料庫連不上!";

//設定使用UTF8編碼
mysql_query("SET NAMES 'utf8'");

//選擇資料庫
mysql_select_db('tad0616');


$op=isset($_POST['op'])?$_POST['op']:"";
$class_sn=isset($_POST['class_sn'])?intval($_POST['class_sn']):"";

if($op=="update"){
  //SQL更新語法
  $sql="update tncomu_class set `seme`='{$_POST['seme']}', `subject`='{$_POST['subject']}', `class_name`='{$_POST['class_name']}', `teacher`='{$_POST['teacher']}', `passwd`='{$_POST['passwd']}', `access`='{$_POST['access']}' where class_sn='$class_sn'";
}else{
  //SQL新增語法
  $sql="insert into tncomu_class (`seme`, `subject`, `class_name`, `teacher`, `passwd`, `access`) values('{$_POST['seme']}' , '{$_POST['subject']}' , '{$_POST['class_name']}' , '{$_POST['teacher']}' , '{$_POST['passwd']}' , '{$_POST['access']}')";
}


//執行SQL語法
mysql_query($sql) or die("無法執行:".mysql_error());

//執行完轉向
header("location: index.php");
?>


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D527%26tbsn%3D20

書籍目錄

展開 | 闔起

線上使用者

65人線上 (27人在瀏覽線上書籍)

會員: 0

訪客: 65

更多…