Creating Search Results from a drop down list

10 posts by 2 authors in: Forums > CMS Builder
Last Post: May 2, 2008   (RSS)

By Liz1001 - March 29, 2008

Hi There;
I have read all the info on searching and other posts on using search, but am still having problem understanding what I need to do. I have created a search page that has a drop down list of products. I want to be able to make it so that when someone selects one of the items from the drop down list it will output all the cities that carry that product. Then on the results page, I want the cities to be hyper linked to a page that display all the clients in that city.

Sorry, I am still pretty new at php and feel like I know enough only to get me into trouble, I am sure this is possible. Thanks for any help

Re: [Liz1001] Creating Search Results from a drop down list

By Dave - March 31, 2008

Hi Liz, Welcome to the forums! :)

We can help you with that. A few questions first:

Have you created any sections editors or html mockups for the website pages yet or are you just getting started?

So the site will have sections for: products, cities, and clients?

Is there a max limit on the number cities a product or client will be in? If we knew there was going to be a max of say 5 cities, we could create an editor for products and clients and then have 5 pulldown fields for cities.

Let me know how many cities there needs to be and we'll figure something out.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Creating Search Results from a drop down list

By Liz1001 - March 31, 2008 - edited: March 31, 2008

Hi Dave - thanks for helping me out, I figured out some of the things like creating a form with a pull down list that sends the product chosen to a second page. http://www.therichlawncompany.com/?page_id=51

Where I am having a problem is only listing on the second page the actual cities that have that product chosen.

Then I am not sure how to make it so that when you click on the city it shows a page with all the dealers. I have contacted the consulting team for help and will be happy to work with them (and pay for time) to resolve this as it is pretty specific to my situation so not sure if the forum is the right place?

Oh and to add more fun to the situation the whole thing is integrated into WordPress. :)

Re: [Liz1001] Creating Search Results from a drop down list

By Liz1001 - March 31, 2008

Dave - sorry I did not really answer your questions:

Have you created any sections editors or html mockups for the website pages yet or are you just getting started?

Yes, the sections are created.

So the site will have sections for: products, cities, and clients?

I just need to output cities that stock a certain product then display the clients in that city.

Is there a max limit on the number cities a product or client will be in?

There are a max # of products, but infinite cities.
Likewise there are more than one clients in a city

Re: [Liz1001] Creating Search Results from a drop down list

By Dave - March 31, 2008

So, each dealer will only be in one city right? If you had a section for "dealers" you could have a field for "City" (which could actually be a list field that loads the city names from the city section. That you could list all the dealers in a specific city with an url like this:

dealerList.php?city=Vancouver

Then, for your city section, you could have a textbox that listed all the products or product numbers (one per line) then you could list all the cities a product was available in with an url like this:

cityList.php?product_keyword=pasta

Does that make sense? Give that a try and let me know how it goes (or let me know if you need more details!) :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Creating Search Results from a drop down list

By Liz1001 - April 30, 2008

Hi Dave;

If I understand your message, I think am trying to work it from a different angle. I have a list of products that when one is selected, shows the list of cities, the city when clicked, shows a list of dealers in that city. But I have some problems with the search results.

I have a page where you can search for a product from a drop down list http://www.therichlawncompany.com/?page_id=72

Problems I am having:
1. The results page shows the city name multiple times, not sure how to fix that. Here is the code:
<h1>Dealers City List Viewer</h1>
<?php foreach ($listRows as $record): ?>
<a href="http://www.therichlawncompany.com/?page_id=53&city_match=<?php echo $record['city'] ?>"><?php echo $record['city'] ?></a><br/>
<hr/>
<?php endforeach ?>


2. Then the cities are actually displaying all the records for that city, not just the ones that have the product that was selected. So I need to edit the code so that only the cities with that product show.

I opened a support ticket back in early March to help with this, I think it was Jake that was helping me, but can not find the emails from him, so not quite sure.

Thanks for any help, I thought we had it working but the client entered the data and that is when I realized there was a problem.
Liz

Re: [Liz1001] Creating Search Results from a drop down list

By Dave - April 30, 2008

Hi Liz,

How are your sections setup? Do you have a separate section for products, cities, and dealers or are they all combined?

Let me know a bit more information about how it's setup and we'll help you get it all fixed up for you. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Liz1001] Creating Search Results from a drop down list

By Dave - May 1, 2008 - edited: May 1, 2008

Hi Liz,

That one's a little tricky, but I think I have an idea on how to make it work the way you want. Try this:

<h1>Dealers City List Viewer</h1>
<?php foreach ($listRows as $record):
if ($record['city'] == @$lastCity) { continue; } // only list cities once
$lastCity = $record['city'];

?>
<a href="http://www.therichlawncompany.com/?page_id=53&city_match=<?php echo $record['city'] ?>"><?php echo $record['city'] ?></a><br/>
<hr/>
<?php endforeach ?>


I saw you took the page offline. Is there a test url we can use while figuring this out? If you're in a rush on this feel free to email me CMS and FTP login directly at dave@interactivetools.com and I can help you get it fixed faster.

Let me know if the above code helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Creating Search Results from a drop down list

By Liz1001 - May 2, 2008

Dave, thanks that worked great, now we only have one city showing. I still have dealers showing up when they do not carry the product, so will email you directly for that,

Thank You
Liz