Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/admin/articleactive.php
<?php 
	session_start();
	include ('../config.php');
	include ('secureadmin.php');
	include ('paginator.php');
	
 if($_POST['delete']) // from button name="delete"
	 {
	 $checkbox = $_POST['checkbox'];
	 $count = count($checkbox);
	 for ($i=0;$i<=$count;$i++){
	 	$sql = "DELETE from `articles` WHERE `id`=".$checkbox[$i].";";
	 	$query = mysql_query($sql);
	 }
	 header('Location: articleactive.php');
	 }  
  
	if(isset($_GET['deleteid'])) { 
	
	$deleteid = $_GET['deleteid'];
	
		$sql = "DELETE from `articles` WHERE `id`=".$deleteid.";";
			$query = mysql_query($sql);
			header('Location: articleactive.php');
			exit();	
}

	$metatitle = "Active Articles - Admin Control Panel";	
	include ('includes/document_head.php');

?>
		<div id="wrapper">
			<?php include 'includes/topbar.php'?>		
			<?php include 'includes/sidebar.php'?>
			<div class="main_container container_16 clearfix">
				
<!-- CONFIRM DELETE -->
<script type="text/javascript">
function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete this article? It will be removed immediately.")) {
    document.location = delUrl;
  }
}
</script>

<?php 
// Setup pagination controls
	$rowsquery = "select * from articles where status=0";
	$rowsresults = mysql_query($rowsquery,$connection) or die(mysql_error());
	$rows_results = mysql_num_rows($rowsresults);
	
	$pages = new Paginator;
	$pages->urlparam = "?";
	$pages->items_total = $rows_results;
	$pages->mid_range = 9;
	$pages->paginate();

	if ($pages->items_total) {	
		$query = "select * from articles where status=0 order by date asc ".$pages->limit;
	} else {
		$query = "select * from articles where status=0	order by date asc";
	}

	$articleresults = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($articleresults);
	
	// for display of page #
	$pagenum = $_GET['page'];
	if (!$pagenum)
		$pagenum = 1;
		

?>

			<div class="flat_area grid_16">
			
				<h2>Active Articles (<?php echo $rows_results; ?>)</h2>
				<p>These articles have been approved and are currently live across your directory.</p><br/>
				<?php echo "<div style=\"float:right; font-weight: bold;\">(Page ".$pagenum.") &nbsp; &nbsp;".$pages->display_pages()."</div><br/>"; ?>
			</div>
			<div class="box grid_16 round_all">
				<form action="articleactive.php" method="post">
				<table width="100%" class="listing"> 
					<thead> 
						<tr> 
							<th width="5%"></th>
							<th width="5%">ID</th> 
							<th width="8%">Date</th>
							<th width="47%">Title</th> 
							<th width="15%">Author</th> 
							<th width="25%">Actions</th>
						</tr> 
					</thead> 
					<tbody> 
					
					
<?php 

		
	for ($i=0; $i <$num_results; $i++) { 
		$row = mysql_fetch_assoc($articleresults);
		
		$date = strtotime($row['date']);
		$artdate = date('m/d/y', $date);
		
		// Get Author Display Name
		$authquery = "select * from authors where id=".$row['authorid']; 
		$authresult = mysql_query($authquery,$connection) or die(mysql_error());
		$authinfo = mysql_fetch_assoc($authresult);
		
		// Get Views
		$viewquery = "select * from articleviews where articleid=".$row['id']; 
		$viewresult = mysql_query($viewquery,$connection) or die(mysql_error());
		$viewinfo = mysql_fetch_assoc($viewresult);
		$views = $viewinfo['views'];
		if (!$views) $views = "-";

		if($row['status'] == 0) {
			$status = "Active";
		} elseif($row['status'] == 1) {
			$status = "In Review";
		} else {
			$status = "Problem";
		}
		
		echo "<tr> <td> <input type='checkbox' name='checkbox[]' id='checkbox[]'  value=".$row['id']." /> </td> 
			 <td>".$row['id']."</td> 
			 <td>".$artdate."</td> 
			 <td><a href=\"articleedit.php?id=".$row['id']."\">".$row['title']."</a></td>
			 <td><a href=\"authoredit.php?id=".$authinfo['id']."\">".$authinfo['displayname']."</a></td>
			 <td> <a href=\"markproblem.php?id=".$row['id']."\">Mark Problem</a> | <a href=\"javascript:confirmDelete('articleactive.php?deleteid=".$row['id']."')\">Delete</a></td></tr>";
		}
?>

					</tbody> 
				</table>
			</div>
<?php 

//display pagination
		echo "<div style=\"float:right; font-weight: bold;\"> (Page ".$pagenum.") &nbsp; &nbsp;".$pages->display_pages()."</div><br/>";

?>			
		<input id='delete' type='submit' name='delete' value="Delete Checked Articles" class="button_colour round_all">
			</form>
			<br/><br/>
				</div>				
			
			
			


			
		</div>	
<?php include 'includes/closing_items.php'?>
Return current item: ArticleSetup