Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/admin/articleedit.php
<?php 
	session_start();
	include ('../config.php');
	include ('secureadmin.php');
				
$articleid = $_GET['id'];

if (!$_GET['id']) { // If directed to update.php without an article ID - Shouldn't ever happen
	header('Location: articleactive.php');
}

// A query to get this article's information 
	$query = "select * from articles where id=".$articleid.";";
				 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$info = mysql_fetch_array($result);
	
	$title = htmlspecialchars($info['title']);
	$body = $info['body'];
	$resource = $info['resource'];
	$category = $info['categoryid'];
	$articleauthor = $info['authorid'];
	$status = $info['status'];
	


	$metatitle = "Edit Article - 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">
				
					
			<div class="flat_area grid_16">
			
	<!-- 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>
		
		
	<div class="box grid_16 round_all">
		<div class="block">
			<h2>Article '<?php echo $title; ?>'</h2>
					
	<br/>
	
	<?php if($status == 1) { //review ?>

	<div style="padding-left: 15px;">
	<table><tr><td><a href="articlereview.php?approveid=<?php echo $articleid; ?>"><button  id="submitstyle" name="save" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Bended Arrow Right.png"><span>Approve Article</span></button></a></td>
	
	<td><a href="markproblem.php?id=<?php echo $articleid; ?>"><button  id="submitstyle" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Flag 2.png"><span>Mark as Problem</span></button></a></td>
	
	<td><a href="javascript:confirmDelete('articlereview.php?deleteid=<?php echo $articleid; ?>')"><button id="submitstyle" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Trashcan.png"><span>Delete Article</span></button></a></td></tr></table>
	</div>
		
							
		<?php } elseif($status == 0) { //active ?>

	<div style="padding-left: 15px;">
	
	<table><tr><td><a href="markproblem.php?id=<?php echo $articleid; ?>"><button  id="submitstyle" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Flag 2.png"><span>Mark as Problem</span></button></a></td>
	
	<td><a href="javascript:confirmDelete('articlereview.php?deleteid=<?php echo $articleid; ?>')"><button id="submitstyle" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Trashcan.png"><span>Delete Article</span></button></a></td></tr></table>
	</div>
			
		<?php } elseif($status == 2) { //problem ?>
		
	<div style="padding-left: 15px;">
	<table><tr><td><a href="articlereview.php?approveid=<?php echo $articleid; ?>"><button  id="submitstyle" name="save" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Bended Arrow Right.png"><span>Approve Article</span></button></a></td>
		
	<td><a href="javascript:confirmDelete('articleproblem.php?deleteid=<?php echo $articleid; ?>')"><button id="submitstyle" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Trashcan.png"><span>Delete Article</span></button></a></td></tr></table>
	</div>

		<?php } ?>


	<form style="padding-left: 15px;" name="submission" method="post" action="articlereview.php" >

	<div style="clear:both"></div>

	<p><b>Article title:</b></p>
	<input type="text" name="title" style="width:400px;" value="<?php echo $title; ?>">
	
	<p><b>Category:</b></p>
	<select name="category">
<?php 
// Function to determine which <option> is selected
	function selected ($categoryid, $rowid) { 
		if ($categoryid == $rowid) {
		return 'SELECTED';
		}
	}
	
// Populates the Dropdown list with all categories and subcats
	$query = "select * from categories where parentid is null;"; 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($result);
		
	for ($i=0; $i <$num_results; $i++) { 
		$row = mysql_fetch_assoc($result); 
		echo "<option ".selected($category, $row['id'])." value=\"".$row['id']."\">".$row['name']."</option><br/>"; 
			$query = "select * from categories where parentid =".$row['id'].";"; 
			$sub_result = mysql_query($query,$connection) or die(mysql_error());
			$sub_num_results = mysql_num_rows($sub_result);
			for ($x=0; $x <$sub_num_results; $x++) { 
				$subrow = mysql_fetch_assoc($sub_result); 
				echo "<option ".selected($category, $subrow['id'])." value=\"".$subrow['id']."\"> -- ".$subrow['name']."</option><br/>";
			}	

	}
?>
</select>

	<br/><br/><p><b>Article body:</b></p>
	</h3><textarea id="body" name="body" style="width:720px; height: 300px;"><?php echo $body; ?></textarea>

	<br/><br/><p><b>Resource box:</b></p>
	</h3><textarea id="resource" name="resource" style="width:720px; height: 120px;"><?php echo $resource; ?></textarea>

	<br />
		<button type="submit" id="submitstyle" name="save" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Bended Arrow Right.png"><span>Submit Changes & Approve</span></button>

	<input name="update" type="hidden" id="update" />
	<input name="articleid" type="hidden" value="<?php echo $articleid; ?>" />
</form>
		
	
			</div>
		</div>


		

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