coding help?
6 posts by 4 authors in: Forums > CMS Builder
Last Post: November 2, 2011 (RSS)
By Toledoh - November 1, 2011
I don't know what I'm doing here - maybe someone can help?
I'm trying to identify the "month" in a date field...
<?php if ($lastMonth != echo date("M", strtotime($gigs_events['date'])): ?>
I guess one of these days I need to read a php for dummies book!
Tim (toledoh.com.au)
Re: [Toledoh] coding help?
By Dave - November 2, 2011
I can't really tell without the code that sets $lastMonth, but try removing the "echo" and let me know if that makes a difference.
Hope that helps!
interactivetools.com
Re: [Dave] coding help?
By Toledoh - November 2, 2011
<?php $lastMonth = ''; ?>
<?php foreach ($gigs_eventsRecords as $gigs_events): ?>
<?php if ($lastMonth != date("M", strtotime($gigs_events['date'])): ?>
<h2><?php date("M", strtotime($gigs_events['date'])) ?></h2>
<?php endif; ?>
<?php $artist = $artistsByNum[$gigs_events['artist']] ?>
<?php foreach ($artist['image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" style="float:left; margin-right:20px;">
<?php endforeach ?>
<h2><?php echo $gigs_events['artist:label'] ?> at
<?php if ($gigs_events['location'] == 'Manly'): ?>Manly
<?php elseif ($gigs_events['location'] == 'Brewery'): ?>The Brewery
<?php endif ?></h2>
<?php echo date("D, M jS, Y", strtotime($gigs_events['date'])) ?>, <?php echo $gigs_events['time'] ?><br />
<p><?php echo $gigs_events['description'] ?><p>
<?php if ($artist['url']): ?><a href="<?php echo $artist['url'] ?>" target="_blank"><img src="assets/images/link_website.png" alt="Website"></a><?php endif ?>
<?php if ($artist['facebook']): ?><a href="<?php echo $artist['facebook'] ?>" target="_blank"><img src="assets/images/link_facebook.png" alt="Facebook"></a><?php endif ?>
<?php if ($artist['twitter']): ?><a href="<?php echo $artist['twitter'] ?>" target="_blank"><img src="assets/images/link_twitter.png" alt="Twitter"></a><?php endif ?>
<div class="clearfix"></div>
<?php $lastMonth = date("M", strtotime($gigs_events['date'])); ?>
<?php endforeach ?>
<?php if (!$gigs_eventsRecords): ?>
Nada - come back soon!
<?php endif ?>
Tim (toledoh.com.au)
Re: [Toledoh] coding help?
By Djulia - November 2, 2011
<h2><?php echo date("M", strtotime($gigs_events['date'])) ?></h2>
Re: [Toledoh] coding help?
By Jason - November 2, 2011
You're missing a closing bracket on your if statement. Try this combined with Djulia's suggestion like this (changes in blue):
<?php $lastMonth = ''; ?>
<?php foreach ($gigs_eventsRecords as $gigs_events): ?>
<?php if ($lastMonth != date("M", strtotime($gigs_events['date']))): ?>
<h2><?php echo date("M", strtotime($gigs_events['date'])) ?></h2>
<?php endif; ?>
<?php $artist = $artistsByNum[$gigs_events['artist']] ?>
<?php foreach ($artist['image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" style="float:left; margin-right:20px;">
<?php endforeach ?>
<h2><?php echo $gigs_events['artist:label'] ?> at
<?php if ($gigs_events['location'] == 'Manly'): ?>Manly
<?php elseif ($gigs_events['location'] == 'Brewery'): ?>The Brewery
<?php endif ?></h2>
<?php echo date("D, M jS, Y", strtotime($gigs_events['date'])) ?>, <?php echo $gigs_events['time'] ?><br />
<p><?php echo $gigs_events['description'] ?><p>
<?php if ($artist['url']): ?><a href="<?php echo $artist['url'] ?>" target="_blank"><img src="assets/images/link_website.png" alt="Website"></a><?php endif ?>
<?php if ($artist['facebook']): ?><a href="<?php echo $artist['facebook'] ?>" target="_blank"><img src="assets/images/link_facebook.png" alt="Facebook"></a><?php endif ?>
<?php if ($artist['twitter']): ?><a href="<?php echo $artist['twitter'] ?>" target="_blank"><img src="assets/images/link_twitter.png" alt="Twitter"></a><?php endif ?>
<div class="clearfix"></div>
<?php $lastMonth = date("M", strtotime($gigs_events['date'])); ?>
<?php endforeach ?>
<?php if (!$gigs_eventsRecords): ?>
Nada - come back soon!
<?php endif ?>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] coding help?
By Toledoh - November 2, 2011
Tim (toledoh.com.au)