User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 540 | Replies: 3 | Solved
Reply
Join Date: Dec 2007
Posts: 5
Reputation: ybn1197 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ybn1197's Avatar
ybn1197 ybn1197 is offline Offline
Newbie Poster

Help Problem with $_GET and JOIN

  #1  
Dec 4th, 2007
Hi all -
I'm hoping someone here can help me with this as I have been trying to figure it out for the past 48 hours and have made little progress.
I have two table in my database. The Primary Key (Serial) in tblTitles is the Foreign Key(Serial) in tblQuotes.
Running the following code will list everything properly. But it lists EVERY row from the database.

  1. $query = "SELECT * from tblQuotes, tblTitles WHERE tblQuotes.Serial = tblTitles.Serial"; //Make the query
  2. $result = @mysql_query ($query); // Run the query
  3. while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  4. {
  5. echo "<a href='./clips/{$row['FileDirectory']}/{$row['Serial']}/{$row['FileName']}.wav'>{$row['Quote']}</a> <br>" .
  6. "{$row['Title']}, {$row['FileSize']}kb <br><br>";
  7. }

What I want is to only list information based on the Serial entry (there are over 2300 rows in the database and over 190 different Serial entries.) I've tried a number of different ways, but I can't get any records to list on the web page. I'm fairly new to this so please dummy it down for me.

Latest attempt:
  1. $serial = $_GET['Serial'];
  2. $query = "SELECT * FROM tblDWWA INNER JOIN tblTitles ON tblDWWA.Serial = tblTitles.Serial WHERE Serial = $serial"; //Make the query
  3. $result = @mysql_query ($query); // Run the query
  4. while($row = @mysql_fetch_array($result)) {
  5. echo "<a href='./clips/{$row['FileDirectory']}/{$row['Serial']}/{$row['FileName']}.wav'>{$row['Quote']}</a> <br>" .
  6. "{$row['Title']}, {$row['FileSize']}kb <br><br>";
  7. }
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Problem with $_GET and JOIN

  #2  
Dec 4th, 2007
Originally Posted by ybn1197 View Post
Running the following code will list everything properly. But it lists EVERY row from the database.
$query = "SELECT * from tblQuotes, tblTitles WHERE tblQuotes.Serial = tblTitles.Serial";


The above query is perfect and i dont know WHY it lists every row !
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 487
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 73
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Problem with $_GET and JOIN

  #3  
Dec 4th, 2007
In your second attempt you are using Serial in your WHERE clause which is an ambiguous field. So just pick a table and use that as the parent to the field. IE., tblQuotes.Serial
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
Reply With Quote  
Join Date: Dec 2007
Posts: 5
Reputation: ybn1197 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ybn1197's Avatar
ybn1197 ybn1197 is offline Offline
Newbie Poster

Re: Problem with $_GET and JOIN

  #4  
Dec 4th, 2007
Thank you. That solved it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC