search script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

search script

Post 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
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

why dont you make it from scratch?

try it and we will help you! ;)
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

sounds like a plan...

Post by th3monk3y »

thanks... I will give it a go.. I will post for help here!
-Paul
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

Post 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
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

Post by th3monk3y »

got it!

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

thanks!
-Paul
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

Well done! as you can see.. you only have to try!..

cheers!!!
Post Reply