PDA

View Full Version : So close - listYear dropdown selection


neubeedoo
03-29-2006, 05:23 PM
OK -
I found the "How do I add a Date Selection Drop-down Menu?" in the knowledge base - not exactly what I needed, but a start!

I have an archive page that is list mode only.
If I was just interested in showing "last year", I would use:
$listYear=date(Y)-1;
and that works great.

BUT
What I want is that exact same page, to initially show all events in listmode for "last year"
WITH a dropdown selection to choose from all the years in the archive.
My archive only goes back to 2004.

I have successfully made the dropdown selection work (though I'm stumped on applying the 'echo SELECT' and making it work)
however the initial page load as 'last (full) year' is elluding me -
(In my playing around, got it once to onload show last year, but it only showed the current month of last year)

Here is my code:
<?php
$arcstart=date(Y)-1; //This sets start year of archive
?>
<form name="form3" method="post" action="<?php echo $PHP_SELF ?>">
<select name="arcyr" id="arcyr">
<?php
for ($N=2004;$N<=$arcstart; $N++) {
echo "<option";
//if ($N==WHAT?HERE?) echo " SELECTED"; //want selected to initially be $arcstart and then change and stick to selected when click go ?HOW??
echo ">$N</option>";
}
?>
</select>
<input type="submit" name="Submit" value="Go">
</form>

and the listMode code:<?php
// SHOW LISTINGS MODULE
$epcListMouseover=1;
$LIST=1;
$DF = "M jS, Y (D)";
$listYear= "$arcyr"; // THIS SUCCESSFULLY takes the submit, but how do I get the initial page load to display all last year ($arcstart)
$template="modern.php";
require("calendar.php");
?>
page in question here: http://s156360743.onlinehome.us/calendar/demo2.php

I'm not that great with php or code - as you can tell, but I'm really trying to grasp on!

Any pointers?
- kathy

ve9gra
03-29-2006, 08:38 PM
I can help you with this, but won't really have any time until tomorrow. Please send me a reminder if I forget to reply.

neubeedoo
03-30-2006, 09:03 PM
No problem - help appreciated whenever you can manage!
- thanks so much!
- kathy

neubeedoo
04-06-2006, 02:55 PM
I Please send me a reminder if I forget to reply.

Hi Ve9gra -
Just a friendly reminder plea on this when you can ...

thanks!

ve9gra
04-06-2006, 08:40 PM
So sorry about this... it totally slipped my mind...

I think I got this code right but I haven't tested it at all.. Please test it and let me know.

<?php
$arcstart = 2004;
$arcend = date("Y") - 1;
if(isset($_REQUEST['arcyr'])) $arcyr = $_REQUEST['arcyr'];
if(!isset($arcyr)) $arcyr = $arcend;
?>
<form name="form3" method="get" action="<?php echo $PHP_SELF ?>">
<select name="arcyr" id="arcyr">
<?php
for ($N=$arcstart;$N<=$arcend; $N++) {
echo "<option value=\"$N\"".(($N==$arcyr)? " SELECTED" : "").">$N</option>\n";
}
?>
</select>
<input type="submit" name="Submit" value="Go">
</form>

neubeedoo
04-06-2006, 09:18 PM
THANK YOU SO VERY MUCH!
Works beautifully!!

- kathy