Page 1 of 1

search script

Posted: Fri Dec 26, 2003 2:13 pm
by th3monk3y
Hi All,
I am new to php (moved over from perl) So I am learning php by example! I am looking for a search script like the one found here:

http://www.iphotocentral.com/search/search.php

I need to be able to search between dates using a dropdown or series of dropdowns yyyy-mm-dd ( I beleive that is mysql's default) as well as have a few other drop downs... I am really having a tough time finding a script like this! most of the examples I have come across are very simple search forms and only have one or two fields, which doesn't enable me to actually "build" a query!

Thanks in Advance,
-Paul

Posted: Fri Dec 26, 2003 2:48 pm
by AVATAr
why dont you make it from scratch?

try it and we will help you! ;)

sounds like a plan...

Posted: Fri Dec 26, 2003 3:08 pm
by th3monk3y
thanks... I will give it a go.. I will post for help here!
-Paul

Posted: Sun Dec 28, 2003 7:04 pm
by th3monk3y
Avatar, thanks for pushing me :D

so far so good! I was almost done and now I am trying to throw one more form variable into the mix! It is killing me!

I have a select box in my form that submits to seperate document list.php

All Counties = ALL
Residential = R
Vacant Land = V

the results get paged on list.php via a url string. for some reason, the variable is not getting cleared when All Counties is selected value="ALL" and I end up with &type= in my url string, when I don't want it there! I get the first 10 results and then when I click on Next 10, My query gets screwed up! if I choose Residential or Vacant Land it sails through all the pages no problem!

if ($type != "ALL"){
$query .= " AND TYPE = '$type'"; // builds on my query
$var2 = "&type=$type"; // this builds into the url string
} else {
$type = ""; // this is where I am hoping to clear out these variables if $type = ALL!
$var2 = "";
}

I have a similar snippet above it for Counties which works just fine. Although it is numerical

$allCounties = 0;
if ($county > $allCounties){
$query .= " AND COUNTY = $county";
$var1 = "&county=$county";
} else {
$county = "";
$var1 = "";
}

I am probably overlooking the obvious! :?

thanks,
-Paul

Posted: Sun Dec 28, 2003 7:24 pm
by th3monk3y
got it!

if ($type=="R" || $type=="V"){
$query .= " AND TYPE = '$type'";
$var2 = "&type=$type";
} else {
$type = "";
$var2 = "";
}

thanks!
-Paul

Posted: Sun Dec 28, 2003 11:01 pm
by AVATAr
Well done! as you can see.. you only have to try!..

cheers!!!