At 15:26 12.01.2001 -0500, Asendorf, John wrote:
>I have a set of date selectors which then people can use to search between
>two dates.  Even though they say FROM and TO, people will undoubtedly put
>the dates in the wrong order on occassion.  If this happens (I've already
>got the IF statement), I want to be able to switch the two dates before the
>SQL is written instead of having it

hmm, not sure, maybe a temp variable is the best, but you could also do the 
following:

<?php
  $from = 14;
  $to = 12;

  /* 1 */
  $array = array("from" => (($from > $to) ? $to : $from), "to" => (($to < 
$from) ? $from : $to));
  echo $array["from"], " - ", $array["to"], "<br />";

  /* 2 - maybe you're even getting an array as input
   <form method=post><input type="text" name="date[0]">
   <input type="text" name="date[1]"><input type=submit></form>
   */
  $array = array(0 => 14, 1 => 12);
  if($array[0] > $array[1]) $array = array_reverse($array);
  echo $array[0], " - ", $array[1], "<br />";
?>

>die ("Hey idiot, go back and switch the dates you've entered");
>
>:)

would be nice anyway :)

daniel

/*--
daniel beulshausen - [EMAIL PROTECTED]
using php on windows? http://www.php4win.de


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to