<?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($_REQUEST['op'])?$_REQUEST['op']:"";
$class_sn=isset($_REQUEST['class_sn'])?intval($_REQUEST['class_sn']):"";
if($op=="delete"){
//設定SQL語法
$sql="delete from `tncomu_class` where class_sn='{$class_sn}'";
//執行SQL語法
mysql_query($sql) or die("無法執行:".mysql_error());
//執行完轉向
header("location: index.php");
}
//設定SQL語法
$sql="select * from `tncomu_class` order by seme desc, subject";
//執行SQL語法
$result = mysql_query($sql) or die("無法執行:".mysql_error());
$main="<table border=1>";
while($data=mysql_fetch_assoc($result)){
$main.="
<tr>
<td>{$data['class_sn']}</td>
<td>{$data['seme']}</td>
<td>{$data['subject']}</td>
<td>{$data['class_name']}</td>
<td>{$data['teacher']}</td>
<td>{$data['passwd']}</td>
<td>{$data['access']}</td>
<td><a href='index.php?class_sn={$data['class_sn']}&op=delete'>刪除</a> | <a href='add_class.php?class_sn={$data['class_sn']}&op=edit'>編輯</a></td>
</tr>";
}
$main.="</table>
";
$tool="<a href='add_class.php'>新增班級</a>";
echo $tool.$main;
//mysq_fetch_row()
//mysq_fetch_array()
?>