Banner depending on user search results

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
macsuibhne
Forum Newbie
Posts: 2
Joined: Mon Sep 24, 2007 5:54 am

Banner depending on user search results

Post by macsuibhne »

I'm setting up a car dealer site and I'm trying to add banners depending on the user results.

If a user searches for an Audi A4, the url displayed in the address bar reads:

http://.............../searchlisting.php?search=1&makems=38&models=25&price=-1&seller=&year=&x=35&y=4

or an A6 will display

http://............../searchlisting.php?search=1&makems=38&models=26&price=-1&seller=&year=&x=31&y=4

makems=38 is always displayed when a user searches for an audi.

I want to know if there is a quick way to display an Audi banner above all Audi results, a BMW banner abover all BMW results, etc.

Anybody got suggestions?

Thanks.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

This is one way you could do it:

First create a relationship between you car model table and a banner table:

1. Create a new table 'tblBanner(intBannerId, strBanner)'
2. Create a another new table 'tblModelBanners(intModelId, intBannerId)' - This will relate your car models with your banners
3. Car Models will now be linked with banners

- tblBanner will contain all the banners you want to use.
- tblModelBanners will relate/link a car model with a particular banner (doing it this way means a model can be linked to more than one banner).

Next what you want to do is retrieve the correct banner for the model requested;

1. Query your database with the 'makems' id
2. User a JOIN to get related records from tblBanner via tblModelBanners
3. Display the banner(s)

Hope this helps!
macsuibhne
Forum Newbie
Posts: 2
Joined: Mon Sep 24, 2007 5:54 am

Post by macsuibhne »

Looks good to me. Thanks.
Post Reply