Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Search function/filter

New Here ,
Nov 16, 2011 Nov 16, 2011

Copy link to clipboard

Copied

I have created a site which advertises companies in all counties of the UK. I have created a drop down menu on the home page so you can select the county you want to search in. Currently all my adverts are placed in the site and the drop down menu is redundant. I would like it so when the user selects the county from the drop down list it filters all the adverts and only shows the adverts in that area, but if no county is selected it will show all the adverts.

Can anyone suggest the best solution to handle this request.

The site is currently online at:

www.myessential.co.uk

You can see the drop down menu is not yet fully populated with all the counties yet but does not currently function.

TOPICS
Server side applications

Views

589
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 16, 2011 Nov 16, 2011

Copy link to clipboard

Copied

The typical way to do this would be to store the content data in a database and build the pages dynamically using a server-side language like PHP.

So, in your database, you would have a table called something like ADVERTS, which would have columns for COMPANY, COUNTY, CATEGORY (such as for Cars, Health, Dining, etc.) and any other relevant columns.

Then, when the visitor selects a COUNTY from the dropdown and a CATEGORY from the menu, the page will be populated according to a database query, such as the following:

SELECT * FROM ADVERTS WHERE COUNTY='$county' AND CATEGORY='$category'

Using this method, you would not have a website with hundreds of pages, but a website with just a few pages that are populated with the releveant content based on the database query. In fact, your whole website could be built using just four or five HTML pages, with all the content being pulled from a database. I don't think there is any other way to achieve what you are after.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2011 Nov 16, 2011

Copy link to clipboard

Copied

Thank you for the reply.

Can the database store images? All my adverts are jpeg images.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 16, 2011 Nov 16, 2011

Copy link to clipboard

Copied

In theory the database can store images, but I can promise you that it isn't necessary or advisable to do so. what you do is upload the image to a directory and store the image file name in the database. so if the images are stored in a folder called "images" the database may simply store the name, like "cocacola.jpg." This would be stored in the same ADVERT table along with the other info.

Then (sing PHP) the image url looks something like this:

<img src="/images/<?php $advert_image ?>"/>

You can also, of course, add the alt tag, image size tags and CSS. The above is just the minimal to demonstrate the point.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2011 Nov 16, 2011

Copy link to clipboard

Copied

LATEST

Use http://php-store-locator.net for the feature you are requesting.

best,

Shocker

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines