Re: Genius help required with PHP MySQL problem
| From: | duirfire | Date: | Fri, 22 Dec 2000 04:00:19 +0000 |
| Subject: | Re: Genius help required with PHP MySQL problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31528@lists.php.net to get a copy of this message | ||
doc,
If you haven't already, add something to verify if the fields have been
filled, if a checkbox has a value, etc.
then take that yes or no, and use it as the logic in an else-if loop.
if yes concat something onto the string variable that holds your SQL.
$sql . "WHERE make ="
The only limit to this one is you have to keep your sql statements
structured fairly strictly, e.g. start with SELECT, if checkbox1 on add WHEN
clause, if checkbox2 on add AND clause etc. Basically, with large forms you
may end up running two SQL statements if you aren't careful.
HTH,
duirfire
On 12/21/00 10:22 PM, "Sefton" <c.sefton@xtra.co.nz> wrote:
> Hello Everybody,
>
> I am trying to return some results from MySql using PHP.
>
> What I have is this...
>
> SELECT * FROM cars WHERE make =
>
> It is after the equals that I want something that will select all of them. I
> know I could just have
> SELECT * FROM cars
> and leave it at that, but my problem occurs when I have another selection
>
> SELECT * FROM cars WHERE make = 'honda' AND trans = 'automatic'
>
> Becuase I am depending on what comes in from select boxes, if they don't
> select a make the code i have returns...
> SELECT * FROM car AND trans = 'automatic'
> This doesn't work for obvious reasons!
>
> So what I am after is something that will always if otherwise decided in the
> select box place
> WHERE make =
> Whatever command will list the lot.
>
> I have tried WHERE make = *
> WHERE make = '*'
> WHERE make = *.*
> etc
>
> Is it possible?
>
> Please Help
>
>
> Thanks
>
> Chris
> Alias Dr nick
>
>