Robert Sossomon wrote:
> I have this code below that needs to display stuff depending on WHEN it
> is.  I
> am pretty sure it is something simple I have confused (again) but can't
> place my
> finger on it.  Anyone see the mistake?
>
>
> <?php
> $today = date("m-d-y");
> $early = date("m-d-y",mktime(0, 0, 0, 1, 14, 2005));
> $normal = date("m-d-y",mktime(0, 0, 0, 1, 31, 2005));
> if ($today <= $early) //also done with writing in "01-14-05"
> {
>   print "<tr><td>Pre-Conference</td><td>$12</td><td><input
> name=\"Pre-Conference\" type=\"radio\" value=\"Y\"></td></tr>";
>   print "<tr><td>Early Registration (thru 01-14-05)</td><td>$85<input
> name=\"Conference\" type=\"radio\" value=\"Early
> Registration\"></td></tr>";
>   print "<tr><td>Registration for Saturday Only (thru
> 01-14-05)</td><td>$65</td><td><input name=\"Conference\" type=\"radio\"
> value=\"Early Saturday Only\"></td></tr>";
> }
> else if ($today >= "01-15-05" || $today <= "01-31-05")

Make this be "elseif" (one word) or you'll some day confuse yourself when
you get nested if/else things going.

Also, you don't want || here, really...
You'd want && to say what you are trying to say.
Dates *WAY* in the future are bigger then 01-15-05, and so they never get
compared to 01-31-05 because you used ||.

At this point, you already *KNOW* that the date is larger than 01-14-05,
so the whole check about 01-15-05 is kinda pointless.

elseif ($today <= "01-31-05") {



A couple other notes.

If you're going to print() out more than a couple lines, just get out of
PHP.  It's going to be easier to maintain your HTML if you do.

Also, you might find this a more natural way to do things:

$today = time();
<?php
if ($today <= mktime(0, 0, 0, 1, 14, 2005){
  ?>
  Early Registration Stuff Here.
  <?php
}
elseif ($today <= mktime(0, 0, 0, 1, 31, 2005){
  ?>
  Normal Registratoin Stuff Here.
  <?php
}
else{
  ?>
  Tell them how great the event was here, and how they should get on the
  mailing list to sign up for next year!
  <?php
}

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to