<?php
include_once("functions/database.php");
include_once("functions/page.php");
include_once("functions/is_login.php");
if (!session_id()){//这里使用session_id()判断是否已经开启了Session
	session_start();
}
if(!is_login()){
	echo "请您登录系统后，再访问该页面！";
	return;
}
?>
<br/>
<form action="index.php?url=news_select.php" method="post" enctype="multipart/form-data">
类别：	
<select name="category_id" size="1">
<?php
include_once("functions/database.php");
get_connection();
$result_set = mysql_query("select * from category");
close_connection();
while($row = mysql_fetch_array($result_set)){
?>
	<option value="<?php echo $row['category_id'];?>"><?php echo $row['name'];?></option>
<?php
}
?>
</select>
<input type="submit" value="查询">&nbsp;<input type="reset" value="重置">
</form>
<table>
<?php
$result_sql = "select * from category";
get_connection();
$result_set = mysql_query($result_sql);
close_connection();

if(mysql_num_rows($result_set)==0){
	exit("暂无记录！");
}
while($row = mysql_fetch_array($result_set)){
?>
<tr>
<td>
	<?php echo $row["name"]?>&nbsp;&nbsp;&nbsp;
</td>
<?php
if(is_login()){
?>
<td>
	<a href="index.php?url=category_edit.php&category_id=<?php echo $row['category_id']?>">编辑</a>
</td>
<td>
	<a href="index.php?url=category_delete.php&category_id=<?php echo $row['category_id']?>" onclick="return confirm('确定删除吗？');">删除</a>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
