SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: results are blank...
-
Dec 20, 2000, 16:20 #1
- Join Date
- May 2000
- Location
- Rocky Mount, NC
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay. I'm working with PHP/mySQL and the results I need are for any game in the Nintendo64 table that starts with "a" to appear. Here is the code I use:
Code:<?php $dbcnx = @mysql_connect("localhost", "172.168.194.94", ""); mysql_select_db("gaming"); $result = mysql_query("SELECT * FROM Nintendo64, Categories, " . "GameLookup WHERE Nintendo64.GameName LIKE 'a%' AND CID=Categories." . "ID AND GID=Nintendo64.ID"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } while ($row = mysql_fetch_array($result)) { $GameName = $row["GameName"]; echo("<b>$GameName</b><br>"); } ?>
Stuart Briscar Consulting - Free Website Consulting
-
Dec 20, 2000, 16:38 #2
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Whay are you selecting from all three tables if you are just looking for games in the Nintnedo64 table that start with a?
Where are CID and GID coming from? I think unless you have a different table structure than the games details all being in the Nintendo table you should be able to just use
SELECT * FROM Nintendo64 WHERE GameName LIKE 'a%'"
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Dec 20, 2000, 16:46 #3
- Join Date
- May 2000
- Location
- Rocky Mount, NC
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is my my table structure:
GAMING is the database
Categories - contains alphabet to shows only games that start with that letter.
Dreamcast - contains dreamcast games
GameLookup - the GID and CID are in here
Nintendo64 - contains nintendo 64 games
PC - contains pc games
Playstation - contains playstation games
Playstation2 - contains playstation 2 games
XBox - contains x-box games
The CID and GID came from Kevin's tutorial.Stuart Briscar Consulting - Free Website Consulting
-
Dec 20, 2000, 17:00 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So there is a record for every game in the GameLookup table where GID is the gameid from the platform table and CID is the category a - z??
GID can't be unique because you have a separate table for each platform Nintendo, Sega, etc....
Sounds like you need to rethink yoiur data structure, If I may suggest have console table that holds all the consoles and then add a field to the GameLookup table that holds the console id then put all your games in one table so you can store the unique game id in the GameLookup table and then you can alos store the console in there that was you can get rid of the Category thing and just lookup the game by passing the console id to the query then you can search throught the gamelookup table for anything starting with a and having the id that corresponds with the console in the Console ID field. Does that make sense?Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Dec 20, 2000, 21:04 #5
- Join Date
- May 2000
- Location
- Rocky Mount, NC
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay. Maybe I should tell you I'm new at this. Could you explain to me what to do as if you were talking to a kindergartner.
Stuart Briscar Consulting - Free Website Consulting
-
Dec 20, 2000, 21:55 #6
- Join Date
- Jul 1999
- Location
- Helena, MT
- Posts
- 287
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
freddydoesphp is right.
The only time when you need to use a lookup table is when you have categories that have a title,description or whatever. But since you are only wanting to seperate everything based on each letter of the alphabet, then you don't need that.
All you need is one table for each console that would list each game's title, description or whatever else you may need and that is it. You don't need a category table or a lookup table in this instance.
Too display all the games starting with an "a", you could just use this select statement (it is based off of the info you used in your other replies):
$result = mysql_query("SELECT * FROM Nintendo64 WHERE GameName LIKE 'a%'");
That query would get all the titles of all the games in the Nintendo64 table, that begin with the letter "a".
Hope this helps.
-
Dec 20, 2000, 22:07 #7
- Join Date
- May 2000
- Location
- Rocky Mount, NC
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Woohoo! It worked Chris, thanks!
Stuart Briscar Consulting - Free Website Consulting
Bookmarks