Search 2 MySQL Table with PHP?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Search 2 MySQL Table with PHP?

Post by influenceuk »

Hi guys,
I have searched all over the place for help with this one.
I am after a script that will allow users to search my site but with a slight twist.

I have 2 tables, each with similar results.
example:
PS3 NTSC
MotorStorm

PS3 PAL
MotorStorm

What i am after is some way to search one of the tables so the user can select either PS3 NTSC or PS3 PAL then it would display the results the user is after.

Any one have any ideas?

Thanks in Advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you explain the table layout more?
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Post by influenceuk »

Ok both table will be the same, however on will hold PAL titles, the other would hold NTSC.

basically it would look like this...

Title | Release Date | Price |

That im after is on the search box, to have a drop down selection for PS3 NTSC, and PS3 PAL.

then depending on which of the PS3 options the user choses it would then search the correct table.

Is that ok? or would you like more, its hard to expalin :(
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Post by influenceuk »

i found this...

http://php.about.com/od/phpwithmysql/ss ... arch_2.htm

which shows the idea of the search bit, however i need it to search 2 tables rather than some coloums. lol just to be awkward!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why not have one table that has a field allowing the selection of NTSC/PAL? An SET field would support this, for example, allowing you to choose either or both.
influenceuk
Forum Commoner
Posts: 42
Joined: Tue May 08, 2007 7:48 am
Location: London, UK

Post by influenceuk »

that is true, i will look into it. its just i was after keeping the 2 formats seperate as its easier to maintain and update lol

let me know if you can work any thing out if not i will rewrite me tables :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The problem is there's a great deal of duplication in having two tables like this.

Generally if I were setting up such a database I would design it where there were probably three tables (with additional linking tables, potentially.) One for the main entry associated with the game; one for secondary titles (i.e. the game goes under a different title in X region, but it's still the same game.) and finally one for platform, media-format, signal-format and price.
The main entry wouldn't hold much of anything, it may in fact be a linking table in fashion. The platform (XBX, X360, PS3, PS2, PS1, PSP, AGB, NGC, etc), media-format (DVD, CD, Cart, UMD, whatever) and signal-format (NTSC, PAL, SECAM, Mesa-SECAM, etc) columns of the third table would likely be SETs.
Post Reply