Re: Simple question that I can't find the answer to

From: Date: Sat, 13 Jan 2001 22:28:35 +0000
Subject: Re: Simple question that I can't find the answer to
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-4983@lists.php.net to get a copy of this message
This doesn't directly address your question but it may be worth being aware of. Depending on which database you're using and how complex the query is and any resulting performance hit, you could try something like: $sql = "select * from table_by_date where date_field between $from_date and $to_date or date_field between $to_date and $from_date" // the reverse order between condition may be illegal in some SQL dialects, but it's accepted by MySQL and postgreSQL $sql = "select * from table_by_date where (date_field >= $from_date and date_field <= $to_date) or (date_field >= $to_date and date_field <= $from_date)" // the less than/greater than alternative to between is acceptable in all SQL's... most SQL's just convert the between form to this any way... In either case the same result is returned, since the reverse order condition(s) returns no rows and the proper order condition(s) returns the desired row set. ~~LF ----- Original Message ----- From: Asendorf, John To: Daniel Beulshausen ; Asendorf, John ; Php-Windows (E-mail) Sent: Friday, January 12, 2001 12:26 PM Subject: RE: [PHP-WIN] Simple question that I can't find the answer to 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 die ("Hey idiot, go back and switch the dates you've entered"); :) --------------------- John Asendorf - jasendorf@lcounty.com Web Applications Developer http://www.lcounty.com - NEW FEATURES ADDED DAILY! Licking County, Ohio, USA 740-349-3631 The benefit to the government of replacing all $1 Federal Reserve notes with $1 coins would be $522.2 million per year, according to estimates of the General Accouting Office released on April 7, 2000. > -----Original Message----- > From: Daniel Beulshausen [mailto:daniel@php4win.de] > Sent: Friday, January 12, 2001 3:29 PM > To: Asendorf, John; Php-Windows (E-mail) > Subject: Re: [PHP-WIN] Simple question that I can't find the answer to > > > At 14:19 12.01.2001 -0500, Asendorf, John wrote: > >Is there a single line of code to do the following? > > > >I'm trying to interchange two variables' contents... I can > do it with the > >following, but I was just wondering... I can't find it if > there is... > > > >$a = "abc"; > >$b = "def"; > > > >$temp = $b; > >$b = $a; > >$a = $temp; > > > >//now $a = "def" and $b = "abc" > > the question would be why you have to exchange the > variablenames, maybe you > can use variable variables $$ or ${}. > i depends on what you want to do. > > daniel > > > /*-- > daniel beulshausen - daniel@php4win.de > using php on windows? http://www.php4win.de > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#4983) next »