Location: PHPKode > projects > JobAppr > Jobappr-1.4/index.php
<?php
#session_start();
require_once('includes/functions.php');
$error=null;

# results requirements: has preview flag, has completed flag and is not expired=Y
if (isset($_POST['q'])) {
	
	# SEARCH VIEW
	$q = cleanLike($_POST['q']);
	$select = "SELECT * FROM ".TB_JOBS." WHERE 
	preview IS NOT NULL 
	AND completed IS NOT NULL 
	AND expired IS NULL 
	AND (
		location LIKE '%".$q."%'
		OR description LIKE '%".$q."%'
		OR company LIKE '%".$q."%'
		OR title LIKE '%".$q."%'
	) 
	ORDER BY category,job_id DESC";
	$result = mysql_query($select);
	$count = mysql_num_rows($result);
	$search = ' Searching '. clean($_POST['q']);
	
} elseif (isset($_GET['c'])) {
	
	# CATEGORY VIEW
	$select = "SELECT * FROM ".TB_JOBS." WHERE category LIKE '".str_replace('-',' ', cleanLike($_GET['c']))."' AND preview IS NOT NULL AND completed IS NOT NULL AND expired IS NULL ORDER BY job_id DESC";
	$result = mysql_query($select);
	$count = mysql_num_rows($result);
	$category = ' Category '. clean($_GET['c']);
	
} else {
	
	# HOMEPAGE VIEW
	$select = "SELECT * FROM ".TB_JOBS." WHERE preview IS NOT NULL AND completed IS NOT NULL AND expired IS NULL ORDER BY category,job_id DESC LIMIT ".meta('frontpage_results');
	$result = mysql_query($select);
	$count = mysql_num_rows($result);	
	
}

?>
<?php get_template('header', $category . $search); ?>
	

	<div id="main" class="noside" >
		<div id="search"><form action="<?php echo BASE_URL; ?>" method="post"><input type="text" name="q" id="q" title="Search Site..." value="<?php echo $_POST['q']; ?>" /> <input type="submit" id="s" name="search" value="Search" /> <?php if ($search) { echo '&nbsp;<a href="'.BASE_URL.'"><em>clear filter</em></a>'; } ?></form></div>
		<a href="<?php echo BASE_URL; ?>post.php" id="postlink" >Post a <?php echo $job_duration; ?> job ad for <?php echo $job_price; ?></a>
		
		<div class="clear"></div>
		
		
		<?php 
			$cat=null;
			if ($count == 0) {
				echo '<p>No results were found. <a href="'.BASE_URL.'">Display all job listings</a></p>';
			} else {
				while($job = mysql_fetch_assoc($result)) {
					if ($job['highlight'] == 'Y') {	$hlt = 'highlight';	} else {$hlt = '';	}
					if ($job['category'] != $cat) {	
						if ($cat != null) {
							echo '</ul><p class="showall"><a href="./category/'.clean_url($cat).'">View All '.$cat.' Listings &raquo;</a></p>';
						}
						echo '<h4>'.$job['category'].'</h4><ul class="joblist" >';	
					} else {	
					}
					$cat = $job['category'];
					$slug = BASE_URL . clean_url($job['location']).'/'.clean_url($job['title']).'/'.$job['job_id'].'/';
					
					echo '<li class="'.$alt.' '.$hlt.'" ><div>'. is_it_new(date("Y-m-d, H:i:s", convert_datetime($job['created']))) .'<b><a href="'.$slug.'">'.$job['title'].'</a></b> &nbsp;at&nbsp; <em>'.$job['company'].'</em> &nbsp;&nbsp;&nbsp; </div><span>'.$job['location'].'</span></li>' ."\n";
					if ($alt == '') {
						$alt = 'alternate';
					} else {
						$alt = '';	
					}
				}
				echo '</ul>';
				if (!$category) { 
					echo '<p class="showall"><a href="'.BASE_URL.'category/'.clean_url($cat).'">View All '.$cat.' Listings &raquo;</a></p>';
				}
			}
		?>

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