-
Need help with PHP declations ($var = ) stuff - RESOLVED
I have a problem that I need someone who knows PHP to help me with.
I am creating a theme for Wordpress and I've created a admin options panel where you can set up some options on the theme. I have a php script on a page that displays only when certain dates are entered in the "$start" declaration. I need to change to month and day choices from the numbers to the declarations from the options panel. I've included the script below. If someone could show me the correct code to replace the "-04-04" in the "$start" declaration to use the "$tohh_month_start" and the "$tohh_day_start" instead of the numbers, I would greatly appreciate it.
<?php
$tohh_timezone = get_option('tohh_ticketbuy_timezone');
$tohh_month_start = get_option('tohh_ticketbuy_month_start');
$tohh_day_start = get_option('tohh_ticketbuy_day_start');
$tohh_month_stop = get_option('tohh_ticketbuy_month_stop');
$tohh_day_stop = get_option('tohh_ticketbuy_day_stop');
date_default_timezone_set('$tohh_timezone');
$today = strtotime(date('Y-m-d'));
$start = strtotime(date('Y') . '-04-04');
$end = strtotime(date('Y') . '-04-20');
if($today >= $start && $today <= $end) { ?>
<!-- START -->
It works!
<!-- END -->
<?php } ?>
Last edited by Relics; 04-06-2010 at 06:58 AM.
-
-
Naturally after I post this, I figure out a working version. I'll post it here for review. Let me know if I'm still doing this wrong or there is a better way to go about doing this. I'm still learning PHP and could use the pointers.
<?php
$tohh_timezone = get_option('tohh_ticketbuy_timezone');
$tohh_month_start = get_option('tohh_ticketbuy_month_start');
$tohh_day_start = get_option('tohh_ticketbuy_day_start');
$tohh_month_stop = get_option('tohh_ticketbuy_month_stop');
$tohh_day_stop = get_option('tohh_ticketbuy_day_stop');
date_default_timezone_set('$tohh_timezone');
$today = strtotime(date('Y-m-d'));
$start = strtotime(date('Y-'.$tohh_month_start.'-'.$tohh_day_start));
$end = strtotime(date('Y-'.$tohh_month_stop.'-'.$tohh_day_stop));
if($today >= $start && $today <= $end) { ?>
<!-- START -->
It works!
<!-- END -->
<?php } ?>
-
-
That's completely correct, assuming everything is consistent with formatting of the variables, etc.
Note that you can now mark this discussion as "Resolved" by editing your first post.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
The Following User Says Thank You to djr33 For This Useful Post:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks