Variations of "else" statement
4 posts by 3 authors in: Forums > CMS Builder
Last Post: June 17, 2016 (RSS)
By degreesnorth - June 5, 2016
Hi Forum
Here's the scenario. Some courses have dates, some don't. And, others are online courses, so they don't need dates. I am currently using the code as
<?php foreach ($calendarRecords as $record): ?>
<?php echo date("D, F jS", strtotime($record['date'])) ?></div></div>
<?php endforeach ?>
<?php if (!$calendarRecords): ?>
Contact us for our next course dates<br/><br/>
<?php endif ?>
That's fine for the "no dates", but
1) the date defaults to Wed, November 30th if there is no date selected
2) how do I say that "if the online course is ticked" <?php echo $record['online_course'] ?> (checkbox), then ignore the dates and replace the "contact us for your next course" with "Start the course now"
Stuck!
Thanks
By Damon - June 7, 2016
Hi,
Can you reply with more code? I'm having trouble following what is needed.
It sounds like you want this:
- Course with course date
- display course with course date - Course without course date
- display course with "Contact us for our next course dates" - Course marked as online
- display course with "Start the course now"
For this date issue:
the date defaults to Wed, November 30th if there is no date selected
Can you provide the steps that cause the default date to be Wed, November 30th?
Can you confirm the setup needed and provide more code details?
Thanks!
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
By degreesnorth - June 7, 2016
Hi Damon
I have two section records:
1) courses - which have the all of the course information. Course either have date(s) which have been assigned, or no dates yet, and then there are also online courses which don't need dates, and
2) calendar - which has the course dates. The fields in this section are:
- course name ('title') which is from a pull down field from the courses records section
- date (date field)
- online course (check box) - if ticked, then it will ignore the date to...
- URL - (text box) ... display the URL to purchase the online course
Yes, you are correct, I want:
- Course with course date
- display course with course date - Course without course date
- display course with "Contact us for our next course dates" - Course marked as online
- display course with "Start the course now" - this is the URL to purchase the online course
The date default to Wed, November 30th occurs when I create a new calendar date and don't select a date (ie, the date box is DAY MONTH YEAR field). If I don't select a date, that's when this problem occurs.
These are the calendar fields
<?php foreach ($calendarRecords as $record): ?>
Record Number: <?php echo htmlencode($record['num']) ?><br/>
Course (value): <?php echo $record['title'] ?><br/>
Course (label): <?php echo $record['title:label'] ?><br/>
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>
Online Course (value): <?php echo $record['online_course'] ?><br/>
Online Course (text): <?php echo $record['online_course:text'] ?><br/>
URL: <?php echo htmlencode($record['url']) ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<hr/>
<?php endforeach ?>
But I don't know how to use the IF / ELSE scenario to enable this to occur. I hope that provides enough information?
Thanks in advance.
By gregThomas - June 17, 2016
Hey degreesnorth,
I understand what you're trying to achieve, but there are a couple of other things I need to know before I can provide sample code. I think it will be quicker for me to look at the structure of your DB directly, please could you fill out a second level support request for me?
http://www.interactivetools.com/support/email_support_form.php
and ensure to include the FTP details for the site so I can see how things are setup.
Thank!
Greg
PHP Programmer - interactivetools.com