Results 1 to 3 of 3

Thread: Need help with PHP declations ($var = ) stuff - RESOLVED

  1. #1
    Join Date
    Jan 2009
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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.

  2. #2
    Join Date
    Jan 2009
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    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 } ?>

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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

  4. The Following User Says Thank You to djr33 For This Useful Post:

    Relics (04-06-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •