Re: Genius help required with PHP MySQL problem
| From: | Sefton | Date: | Fri, 22 Dec 2000 04:33:21 +0000 |
| Subject: | Re: Genius help required with PHP MySQL problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31534@lists.php.net to get a copy of this message | ||
I Like the idea of using the array, but with my limited experience in this
I really don't know how toput it all together.
It should keep me busy over christmas trying to work it out.
"Maxim Maletsky" <maxim.maletsky@japaninc.net> wrote in message
news:DC017B079D81D411998C009027B7112AA93402@EXC-TYO-01...
: well, you don't really need a genius in to help you out with this one.
:
: just assign all these WHERE's to an array:
:
: $query = "SELECT * FROM cars ";
: $where = Array();
: while (list($key, $val) = each($select_box)) {
: if($val)
: $where => "WHERE $key='$val'";
: }
:
: and so on... use any kind of loop like for() or while(). The only thing
you
: need is that an array comes to you from the form having field name as a
key
: and value is what they select. while is a good choise.
:
: then just implode() that all:
:
: $query .= implode(' AND ', $where);
:
: it will generate the string of the whole array separated by ' AND '.
:
:
:
: hope it helps.
: Cheers,
: Maxim Maletsky
:
: -----Original Message-----
: From: Sefton [mailto:c.sefton@xtra.co.nz]
: Sent: Friday, December 22, 2000 12:23 PM
: To: php-general@lists.php.net
: Subject: [PHP] Genius help required with PHP MySQL problem
:
:
: 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
:
:
:
: --
: PHP General Mailing List (http://www.php.net/)
: To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
: For additional commands, e-mail: php-general-help@lists.php.net
: To contact the list administrators, e-mail: php-list-admin@lists.php.net
:
: --
: PHP General Mailing List (http://www.php.net/)
: To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
: For additional commands, e-mail: php-general-help@lists.php.net
: To contact the list administrators, e-mail: php-list-admin@lists.php.net
: