Re: logic operands problem

From: Date: Mon, 07 Dec 2009 14:41:03 +0000
Subject: Re: logic operands problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300283@lists.php.net to get a copy of this message
Hey Merlin Merlin Morgenstern wrote on 2009-12-07 11:52:
Hello everybody, I am having trouble finding a logic for following problem: Should be true if: page = 1 OR page = 3, but it should also be true if page = 2 OR page = 3 The result should never contain 1 AND 2 in the same time. This obviously does not work: (page = 1 OR page = 3) OR (page = 2 OR page = 3) This also does not work: (page = 1 OR page = 3 AND page != 2) OR (page = 2 OR page = 3 AND page != 1) Has somebody an idea how to solve this?
I've read the entire thread and can see that this is a MySQL query you want to make (I was about to tell you about the == comparison and the $ in a variable in PHP). What you want is all results containing 1,2 or 3, so make a "WHERE page IN(1,2,3)" and use PHP logic to figure out if a free slot is available or not. Or rewrite your booking routine (use data and time fields instead, maybe by creating a bunch of free slots and then a booked field with a default of "0", changed to "1" when booked) -- Kind regards Kim Emax - masterminds.dk

« previous php.general (#300283) next »