If NO ENTRY - DISPLAY THIS

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 18, 2019   (RSS)

By csdesign - January 17, 2019

Hello! Thank you in advance for the assistance. I'm hoping it's just something easy and obvious that I'm overlooking. 

I'm posting job listings by location for 5 cities. I'm including the code for one since they are identical, except for the job_location name. 

What I'm trying to achieve is that if there are NO job listings for an individual location to post "No current job listings for this location. Please check back!"
On my screenshot, you can see that there are job listings in Miles City (works fine) but not in Billings - but I'm not getting "No current job listings..." text to show. 

I also tried using the code below and that actually worked but it listed "No current listings..." for all 7 jobs - so 7 times in a row. 

<?php if (strpos($record['job_location'],"\tMiles City MT\t") !== true) : ?>
No current listings for this location
<?php endif ?>

The code below is what I'm working with now. I used "title" in the if/else because that's required for each job listing but it could be job_location too if needed.

Thanks!!!  Tina

<!-- JOBLIST -->
<h2>JOBS IN MILES CITY, MT</h2>
<?php foreach ($careers_listRecords as $record): ?>
<?php if ($record['job_status'] == 'Active'): ?>
<?php if (strpos($record['job_location'],"\tMiles City MT\t") !== false) : ?>
							
	<div class="alert alert-info">
	<strong><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></strong> &nbsp;<a href="<?php echo $record['_link'] ?>"> <i class="icon-line-minus"></i> Job Details <i class="icon-hand-up"></i> </a>
	</div>
							
	<?php if($record['title']) :?>
        <?php else : ?>
	No current job listings for this location. Please check back!
	<?php endif; ?>
					
<?php endif; ?>
<?php endif ?>
<?php endforeach ?>
						

By csdesign - January 18, 2019

Thanks Daniel! It worked like a charm! Thank you also for explaining it!  Have a great day! Tina