Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP PHP events not showing when date is today.

wyclef

Active Coder
Hi, I have some old PHP code I am trying to sort through and it is for pulling 3 upcoming events and I guess it was written so todays event doesn't show and am trying to fix that. I was wondering if anyone can make sense of this?

PHP:
                <ul>
                  <?php  $urlSplits = explode('/', $_SERVER['REQUEST_URI']); ?>
                  <?php
                    if ($urlSplits[3] != '') {
                      $currentYear = $urlSplits[3];
                    } else {
                      $currentYear = date('Y');
                    }
                  ?>
                  <?php  query_posts('cat=3&order=DESC');?>
                  <?php  if (have_posts()) : ?>

                    <?php  while (have_posts()) : the_post(); ?>
                      <?php
                        $eventDate = get_field('start-date', $post->ID);
                        $eventDate = str_replace(', ', ' ', $eventDate);
                        $eventDate = strtotime($eventDate);
                        $eventDateArray[] = $eventDate;
                        $eventPIDArray[] = $post->ID;
                      ?>
                    <?php  endwhile; ?>
                    <?php
                      asort($eventDateArray);
                      $todayDate = date('F-j-Y');
                      $todayDate = strtotime($todayDate);
                    ?>
                    <?php  foreach ($eventDateArray as $k => $v) { ?>
                      <?php  if ($eventDateArray[$k] >= ($todayDate - 100000)) { ?>
                        <?php  $temp = $todayDate - $eventDateArray[$k]; ?>
                        <?php  if ($temp <= 1000000) { ?>
                          <?php  $sortedDateArray[] = $temp; ?>
                          <?php  $sortedPID[] = $eventPIDArray[$k]; ?>
                        <?php  } ?>
                      <?php  } ?>
                    <?php  } ?>
                    <?php  $showPostsCount = 0;?>
                    <?php  if (count($sortedDateArray) > 0) { ?>
                      <?php  foreach($sortedDateArray as $k => $v) { ?>
                        <?php  if ($showPostsCount < 3) { ?>
                          <li>
                            <em><?php  the_field('start-date', $sortedPID[$k]); ?></em>
                            <strong><a href="<?php  echo get_permalink($sortedPID[$k]); ?>" rel="bookmark"><?php  echo get_the_title($sortedPID[$k]); ?></a></strong>
                          </li>
                          <?php  $showPostsCount++; ?>
                        <?php  } ?>
                      <?php  } ?>
                    <?php  } else { ?>
                    <li>
                      <em>No Events Scheduled</em>
                      <strong><?php  _e("Check back soon for upcoming events."); ?></strong>
                    </li>
                    <?php  } ?>
                <?php  else : ?>
                    <li>
                      <em>No Events Scheduled</em>
                      <strong><?php  _e("Check back soon for upcoming events."); ?></strong>
                    </li>
                <?php  endif; ?>
                </ul>

I was thinking it has to do with the following lines in the script above but not entirely sure?

PHP:
<?php  if ($eventDateArray[$k] >= ($todayDate - 100000)) { ?>
                        <?php  $temp = $todayDate - $eventDateArray[$k]; ?>
                        <?php  if ($temp <= 1000000) { ?>

Would appreciate some help with this if possible. Thanks!
 
I have not learned much PHP yet but I think you are correct and should remove that = from first in maybe found with >= and maybe fiddle with +1 or -1 with that other if statement.
X E.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom