RE: [PHP-WIN] Simple question that I can't find the answer to

From: Date: Fri, 12 Jan 2001 22:26:13 +0000
Subject: RE: [PHP-WIN] Simple question that I can't find the answer to
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-4961@lists.php.net to get a copy of this message
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 - daniel@php4win.de using php on windows? http://www.php4win.de

« previous php.windows (#4961) next »