<?php
include_once("functions/is_login.php");
if (!session_id()){//这里使用session_id()判断是否已经开启了Session
	session_start();
}
if(!is_login()){
	echo "请您登录系统后，再访问该页面！";
	return;
}
?>
<form action="index.php?url=category_list.php" method="post">
类别：	
<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><br/>
<input type="submit" value="确定">
</form>
<?php 
if(isset($_POST["category_id"])){
  $category_id = $_POST["category_id"];}
  include_once("functions/database.php");
  get_connection();
  $result1= mysql_query("select * from news where category_id='category_id'");
  close_connection();
if(mysql_num_rows($result1)==0){
	exit("暂无记录！");
}
while($row = mysql_fetch_array($result1)){
?>
<tr>
<td>
	<a href="index.php?url=news_detail.php&keyword=<?php echo $keyword?>&news_id=<?php echo $row['news_id']?>"><?php echo mb_strcut($row['title'],0,40,"gbk")?></a>
</td>
<?php
include_once("functions/is_login.php");
if(is_login()){
?>
<td>
	<a href="index.php?url=news_edit.php&news_id=<?php echo $row['news_id']?>">编辑</a>
</td>
<td>
	<a href="index.php?url=news_delete.php&news_id=<?php echo $row['news_id']?>" onclick="return confirm('确定删除吗？');">删除</a>
</td>
<?php
}
?>
</tr>
<?php
}
?>

