|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Registered
Join Date: Dec 2004
Location: Canada
Posts: 12
Reputation: 5
|
problem accessing 2 tables
Hey everyone, I'm having some trouble with this code i got to access some info from my database, the problem is that i can't access the table i'm querying during the while function. I'm new to php and mysql, but i can't figure out why it won't query the second table, everything else comes out fine. I appreciate any help you can offer
Johnny O Here's my code: PHP Code:
|
|
|
|
|
#2 |
|
Join Date: Sep 2002
Location: Evansville Indiana
Posts: 220
Reputation: 25
|
pull your information out from both tables in the same query:
$query = "SELECT s.s_id, s.song_title, s.views, s.a_id, a.artist_name FROM " . songs . " s, " . artists . " a WHERE a.a_id = '$a_id' ORDER BY s.views DESC" something of that nature should make things less complicated for you, cant guarentee it will work tho, im not expert myself.
__________________
|
|
|
|
|
#3 |
|
foo
Join Date: Jan 2003
Location: Seattle-ish
Posts: 2,597
Reputation: 106
|
You use mysql_close(), so you no longer have a connection to mysql. If you want to combine it all into 2 queries, make sure you use a join.
__________________
webhead.cc |
|
|
|
|
#4 |
|
Older not wiser
Join Date: Nov 2003
Location: Calgary, AB
Posts: 2,473
Reputation: 205
|
With what you you're trying to do you can do an implicit join by using something like this ...
SELECT songs.s_id, songs.song_title, songs.views, songs.a_id, artists.artist_name FROM songs, artists WHERE songs.a_id = a_id ORDER BY songs.views DESC |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|