Archives Issue

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 2, 2013   (RSS)

Hi April,

I think something similar to this post should work well:

http://www.interactivetools.com/forum/forum-posts.php?Array-of-months-from-today-78607

Here is how I would adapt your code:

<form>
  <select name="archive" size="1" onchange="loadPage(this.form.elements[0])" target="_blank" onmouseclick="this.focus()" style="background-color:#ffffff">
    <option value="">Select an Archive</option>
    <?php $i = 1; ?>
    <?php while($i < 4): ?>
      <?php $dateVal = strtotime('-'.$i.' month'); ?>
      <option value="http://www.charlotteparent.com/aboutus/advertising/archives.php?date_year=<?php echo date('Y', $dateVal); ?>&date_month=<?php echo date('n', $dateVal); ?>">
        <?php echo date('Y F', $dateVal); ?>
      </option>
      <?php $i++; ?>
    <?php endwhile ?>
  </select>
</form> 

So $i is used as a counter for the month. Then loop through each value for $i while it's less than 4. $i is then used to convert the month into a date value. This date value is used to display the month in various formats for each option.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By design9 - April 2, 2013

Perfect! Thank you so much!