Re: Help: Database Search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You might want to try looking up the syntax for left join queries.
I think this might be what you are after.

http://dev.mysql.com/doc/mysql/en/JOIN.html


On Wednesday 10 November 2004 14:37, Stuart Felenstein wrote:
> I am creating a database search form and results.
> Running into a problem though.
> I have two form elements, both that are fed by tables
> that have int values (1, 2 , etc)
>
> my sql statement is such:
>
> SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
> vendorjobs.Industry, vendorjobs.VendorID,
> vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
> vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
> Date_Sub(Curdate(), interval '$Days' day) <= PostStart
> "
>
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected:  (Having no luck as the form still
> only works correctly if I've set both elements)
>
> $Ind = "0";
> if (isset($_POST['Ind'])) {
>   $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
> addslashes($_POST['Ind']);
> }
> $Days = "0";
> if (isset($_POST['Days'])) {
>   $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
> addslashes($_POST['Days']);
>
> Thank you ,
> Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux