Re: Database query
| From: | Jon Farmer | Date: | Tue, 18 Dec 2001 13:14:15 +0000 |
| Subject: | Re: Database query | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15084@lists.php.net to get a copy of this message | ||
Sorry the second elseif statement should have ended with : not ;
--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send email with subject: Send PGP Key
----- Original Message -----
From: "Jon Farmer" <jonfarmer@enta.net>
To: <Bzdpltd@aol.com>; <php-db@lists.php.net>
Sent: Tuesday, December 18, 2001 1:12 PM
Subject: Re: [PHP-DB] Database query
> Ok you need to use PHP to decide what they have selected and construct a
sql
> statement based on that.
>
> for instance
>
> if ($location != "" && $discipline != "") :
> //construct variable with sql statement
> elseif ($location == "" && $discipline != ""):
> //construct variable with sql statement
> elseif ($location !="" && $discipline == "");
> //construct variable with sql statement
> else :
> // nothing selected
> endif;
>
>
> hth
>
> Jon
> --
> Jon Farmer
> Systems Programmer, Entanet www.enta.net
> Tel 01952 428969 Mob 07763 620378
> PGP Key available, send email with subject: Send PGP Key
>
> ----- Original Message -----
> From: <Bzdpltd@aol.com>
> To: <php-db@lists.php.net>
> Sent: Tuesday, December 18, 2001 12:49 PM
> Subject: [PHP-DB] Database query
>
>
> > Hi group,
> >
> > I am still getting to grips with PHP and MySQL and have a question that
> hopefully someone can easily answer:
> >
> > I have a search page which consists of two drop down menus, the user has
3
> ways of finding information.
> >
> > The first is by selecting a location and a discipline which would look
in
> the database and return any entries with the data in the two seperate
> fields.
> >
> > The second is where they can select the location only, and this will
> return all entries with that location
> >
> > The third is where they can select the discipline only, and again this
> will return all entries with that discipline.
> >
> > The problem I have is when the user selects the location and a
discipline
> which should return no results as it is not an exact match it is returning
> results as it contains part of the information.
> >
> > My sql query is as follows: $sql = "SELECT * FROM vacancy WHERE
> ('$related_discipline' = related_discipline and '$location' = location) or
> ('$related_discipline' = related_discipline) or ('$location' = location)
> ORDER BY ID LIMIT $limitvalue1, $limit";
> >
> > Could someone tell me what I need to change?
> >
> > Again help is always appreciated.
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>