Here's the code
<?php
include('includes/protect.php');
include('includes/db.php');
if(isset($_GET['del'])){
$del = intval($_GET['del']);
mysql_query("delete from news where id = ".$del);
}
if(isset($_GET['disable'])){
$disable = intval($_GET['disable']);
mysql_query("update news set active = 0 where id =
".$disable);
}
if(isset($_GET['enable'])){
$enable = intval($_GET['enable']);
mysql_query("update news set active = 1 where id =
".$enable);
}
$yearlower = $_GET['year'];
$_SESSION['newsyear'] = $_GET['year'];
$_SESSION['newssort'] = $_GET['sort'];
?>
<?php include('header.php');?>
<table width="100%" id="brieflist">
<td colspan="2"><h2>Manage News Stories
</h2></td>
<td colspan="2">
<p align="right"><select class="option"
name="otheryear" id="otheryear">
<option <?php if (($_GET['year']) == 2007)
{?>selected="selected" <?php
;}?>value="news.php?year=2007&sort=<?php echo
$_GET['sort'];?>">2007</option>
<option <?php if (($_GET['year']) == 2006)
{?>selected="selected" <?php
;}?>value="news.php?year=2006&sort=<?php echo
$_GET['sort'];?>">2006</option>
<option <?php if (($_GET['year']) == 2005)
{?>selected="selected" <?php
;}?>value="news.php?year=2005&sort=<?php echo
$_GET['sort'];?>">2005</option>
<option <?php if (($_GET['year']) == 'all')
{?>selected="selected" <?php
;}?>value="news.php?year=all&sort=<?php echo
$_GET['sort'];?>">All</option>
</select></p>
</td>
<tr>
<td colspan="4">
<br />
<a href="news-add.php">Add News Story </a>
<p><hr />
<br />
</p>
</td>
</tr>
<!-- Header Row -->
<tr>
<td class="columnhead"><a class="columnhead"
href="<?php echo $PHP_SELF;?>?year=<?php echo
$_GET['year']?>&sort=headline"><b>Headline</b></a></td>
<td class="columnhead"><a class="columnhead"
href="<?php echo $PHP_SELF;?>?year=<?php echo
$_GET['year']; ?>&sort=newsdate"><b>Article
Date</b></a></td>
<td
class="columnhead"> <b><u>Actions</u></b></td>
<td align="right" class="columnhead"><a
class="columnhead" href="<?php echo
$PHP_SELF;?>?year=<?php echo $_GET['year'];
?>&sort=active"><b>Status</b></a></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr><td colspan="4"><hr
/></td></tr>
<?php
// status, date, or headline
if ($_GET['sort'] == "newsdate") {
$dateon = 1;
$statuson = 0;
$headlineon = 0;
} elseif ($_GET['sort'] == "active") {
$dateon = 0;
$statuson = 1;
$headlineon = 0;
} elseif ($_GET['sort'] == "headline") {
$dateon = 0;
$statuson = 0;
$headlineon = 1;
}
// sorting rules
if ($statuson == 1) {
$status = " asc, newsdate desc, lastupdate desc";
}
if ($dateon == 1) {
$status = " desc, lastupdate desc";
}
if ($headlineon == 1) {
$status = " asc";
}
// if all years selected
if ($_GET['year'] == 'all') {
$yearlower = 0000;
$yearplus = 9999;
} else {
$yearplus = $yearlower;
}
$get_briefs = mysql_query("select
id,headline,active,newsdate,gbcpr,tpaapr,lastupdate from news where
newsdate >= DATE '".$yearlower."-00-00' AND newsdate <= DATE
'".$yearplus."-99-99' order by ".$_GET['sort'].$status);
$count = 0;
while($brief = mysql_fetch_array($get_briefs)){
$count++;
?>
<tr>
<!-- Headline -->
<td width="500" valign="bottom"><p
class="briefinfo"><b><a href="news-edit.php?id=<?php
echo $brief['id'];?>"><?php echo
$brief['headline'];?></a></b></p></td>
<!-- Date -->
<td width="80" valign="bottom" align="center"><p
class="briefinfo">
<?php
$newsdate = strtotime($brief['newsdate']);
echo date('M j, Y', $newsdate);
?>
</p></td>
<!-- Actions -->
<td width="100" valign="bottom" align="center"><p
class="briefinfo"> <a
href="news-edit.php?id=<?php echo
$brief['id'];?>">Edit</a> | <a href="<?php echo
$PHP_SELF;?>?year=<?php echo
$_GET['year'];?>&sort=<?php echo
$_GET['sort'];?>&del=<?php echo $brief['id'];?>"
onclick="confirm('Are you sure?');return confirm('Are you REALLY
sure?');">Delete</a>
</p>
</td>
<!-- Status -->
<td valign="bottom" align="center"><p class=<?php
if($brief['active']==0) {?> "draft"<?php ;} echo "status";
?> ><?php if($brief['active']==1){?><a
href="<?php echo $PHP_SELF;?>?year=<?php echo
$_GET['year']?>&sort=<?php echo
$_GET['sort'];?>&disable=<?php echo
$brief['id'];?>">published</a><?php }else{?><a
class="draft" href="<?php echo $PHP_SELF;?>?year=<?php
echo $_GET['year']?>&sort=<?php echo
$_GET['sort'];?>&enable=<?php echo
$brief['id'];?>">draft</a><?php }?></p>
</td></tr>
<tr><td colspan="4"><hr
/></td></tr>
<?php }?>
</table>
<?php include('footer.php');?>