Re: [PHP-DB] select from two tables
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I did not look at the code very much but if you want to select from 2 tables your sql statement is like this: select a.col1,b.col1 from table1 a,table2 b where a.column=b.column column='value'; I think that if this is what you are looking for this should help... Caleb On Saturday 27 July 2002 6:17 am, Barry Rumsey wrote: Ok I tired this but it did not help, but thank you. -Original Message- From: Herman Verkade [mailto:[EMAIL PROTECTED]] Sent: Sunday, 28 July 2002 1:18 a.m. To: 'Barry Rumsey' Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] select from two tables Well, I'm just a beginner myself, but I would say that: echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; should at least be: echoi by ; echo ($album[xoops_artist.artist]); echoibr; or even: echoi by ; echo ($album[artist]); echoibr; Hope this helps, Herman - -- Get my GnuPG public key http://www.cwalk.org/pgp_info.html See complete mail headers for more information -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9TGBF6k6xsUuSNSsRAnQmAJ9TT6pB7n8WaqVCHixPobIcTYLEXACfcKFz ce+/GnVVNQvQTansb5feuPg= =Jhay -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select from two tables
I would try replacing: echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; with this: echoi by ; echo $albumby[artist]; echoibr; or even better this(notice the dots instead of different echos and the single qoutes): echo'i by '.$albumby[artist].'ibr'; I would say that you have a coloumn called artist in both tables. that is why it echoing nothing. I have also had trouble with SELECT * with cross-table joins. I would replace it with the fields you need only. Like this: SELECT * xoops_artist.artist, xoops_album.artist etc... this would fixed the problem with coloumns with the same name also -- JJ Harrison [EMAIL PROTECTED] www.tececo.com Herman Verkade [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Well, I'm just a beginner myself, but I would say that: echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; should at least be: echoi by ; echo ($album[xoops_artist.artist]); echoibr; or even: echoi by ; echo ($album[artist]); echoibr; Hope this helps, Herman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] select from two tables
I have the following code: $query = SELECT * FROM xoops_album,xoops_artist WHERE xoops_album.artist_id = xoops_artist.artist_id; $albumby = mysql_query($query) or die(Select Failed!); echotdcenter; if (mysql_num_rows($albumr)) { while ($album = mysql_fetch_array($albumr)) { echo ($album[album]); echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; } echo /center/td; } What I'm trying to do is select the album title from one table ( this works ok ) and get the artist name from another table ( this is the part I can't get to work ). I believe it has something to do with the code above as the rest works ok. The result I end up with is below: Waterloo by ( this is where I want to put the artist name) Thanks for in help in advance.
RE: [PHP-DB] select from two tables
Well, I'm just a beginner myself, but I would say that: echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; should at least be: echoi by ; echo ($album[xoops_artist.artist]); echoibr; or even: echoi by ; echo ($album[artist]); echoibr; Hope this helps, Herman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] select from two tables
Ok I tired this but it did not help, but thank you. -Original Message- From: Herman Verkade [mailto:[EMAIL PROTECTED]] Sent: Sunday, 28 July 2002 1:18 a.m. To: 'Barry Rumsey' Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] select from two tables Well, I'm just a beginner myself, but I would say that: echoi by ; echo ($albumby[xoops_artist.artist]); echoibr; should at least be: echoi by ; echo ($album[xoops_artist.artist]); echoibr; or even: echoi by ; echo ($album[artist]); echoibr; Hope this helps, Herman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select from two tables
Hi Barry $query = SELECT * FROM xoops_album,xoops_artist WHERE xoops_album.artist_id = xoops_artist.artist_id; If you only need two fields, it is not necessary to retrieve all fields $query = SELECT xoops_album.album, xoops_artist.artist FROM xoops_album, xoops_artist WHERE xoops_album.artist_id = xoops_artist.artist_id; $albumby = mysql_query($query) or die(Select Failed!); Your resultset contains then the only two required fields. echotdcenter; if (mysql_num_rows($albumr)) { while ($album = mysql_fetch_array($albumr)) { echo $album[album] iby $album[artist] /ibr; // new line } echo /center/td; } Hope it helps Conni -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php