Location: PHPKode > projects > JobAppr > Jobappr-1.4/admin/jobs.php
<?php 
session_start();
if(!isset($_SESSION['password'])){
	header("Location: index.php");
	exit();
}
if( $_SESSION['role'] != 1 ){
	header("Location: dashboard.php");
	exit();
}
require_once('../includes/functions.php');
require_once('inc/admin-functions.php');

# VARIABLES
$user_id = $_SESSION['user_id'];
$error = null;

# if deleting a job
if(isset($_GET['delete'])) {
$status= mysql_query("DELETE FROM ". TB_JOBS ." WHERE `job_id`='".$_POST['id']."'");
	if($status) {
		$success = 'Job #<b>'.$_POST['id'].'</b> successfully deleted';
	} else {
		$error = mysql_error();
	}
}

# if created a job
if(isset($_GET['created'])) {
	$success = 'New job ad successfully created';
}

?>

<?php get_template('header', 'Active Job Ads'); ?>

	<div id="main">
		<?php display_messages(); ?>
		
		<h1>Active Job Ads</h1>
		<p class="add" ><a href="./add_job.php" class="add" >Add a New Job Posting</a></p>
		<table class="datalist" >
			<tr><th>Job Title</th><th>Company</th><th>Description</th><th>Location</th><th>Posted</th><th class="nothing"></th></tr>
		<?php
		$select = "SELECT * FROM ".TB_JOBS." WHERE preview IS NOT NULL AND completed IS NOT NULL AND expired IS NULL ORDER BY job_id DESC";
		$data = mysql_query($select);
		$count = mysql_num_rows($data);	
		while($job = mysql_fetch_assoc($data)) {
			echo '<tr '.$alt.'><td><a href="./edit_job.php?id='.$job['job_id'].'">'.$job['title'].'</a></td><td>'.trunc($job['company'],20).'</td><td>'.trunc(strip_tags($job['description']),20).'</td><td>'.trunc($job['location'],25).'</td><td>'.date("M j", convert_datetime($job['created'])).'</td><td class="nothing"><a href="'. get_filename().'?delete='.$job['job_id'].'" title="You are about to delete '.$job['title'].'" rel="'.$job['job_id'].'" rel2="job" class="delconfirm"><img src="assets/images/trash.gif" alt="Delete Job" /></a></td></tr>' ."\n";
			if ($alt == '') {
				$alt = 'class="alternate"';
			} else {
				$alt = '';	
			}
		}
		
		?>
		</table>
		
	</div>
	
	
<?php get_template('sidebar'); ?>

<?php get_template('footer'); ?>
Return current item: JobAppr