<?php
require_once("checkstate.php");
?>

<?php
require("connect.php");
?>



<?php    //本處程式是處理新增、刪除、修改

//刪除
if ($_GET['action']=="delete") {
//	echo "here";
	$schnum=$_GET['id'];
	$sql="delete from classmate where schnum='$schnum'";
//echo $sql; exit();
	mysql_query($sql) or die("delete error!");
}

//修改
if ($_GET['action']=="modify") {

}

//新增
if ($_GET['action']=="add_new") {

}
?>



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<style type="text/css">
.aaa {
	font-size: 36px;
	color: #00F;
}
.bbb {
	font-size: 20px;
	color: #093;
	font-weight: bold;
}
</style></head>

<body>
<table width="980" height="818" border="1" align="center">
  <tr>
    <td height="112" colspan="3" align="center" class="aaa">後台管理程式</td>
  </tr>
  <tr>
    <td width="182" valign="baseline"><p>班級通信錄<br />
      　<a href="1_add.php">新增</a><br />
    </p>
      <p>成績冊<br />
        　新增<br />
　刪除<br />
　修改        </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p><a href="logout.php">登出</a><br />
    </p></td>
    <td width="782" colspan="2" align="center" valign="baseline"><p>&nbsp;</p>
      <p class="bbb">通信錄的清單</p>
<?php 
$result=mysql_query("select * from classmate");

?>

      <p>總筆數：<?php echo mysql_num_rows($result);?></p>
      
      
      <table width="657" height="78" border="1" align="center">
      <tr>
        <th width="132" height="34">學號</th>
        <th width="132">姓名</th>
        <th width="132">姓別</th>
        <th width="146">Email</th>
        <th width="81">功能</th>
      </tr>

<?php

while ($object=mysql_fetch_object($result)) {
?>
      <tr>
        <td><?php echo $object->schnum;?></td>
        <td><?php echo $object->name;?></td>
        <td><?php echo $object->gender;?></td>
        <td><?php echo $object->email;?></td>
        <td align="center">修改 <a href="<?php echo $_SERVER['PHP_SELF'];?>?action=delete&id=<?php echo $object->schnum; ?>">刪除</a></td>
      </tr>
      <?php
}
?>
    </table></td>
  </tr>
</table>
</body>
</html>