Re: Display all data from two tables with MySQL query
| From: | Oliver Heinisch | Date: | Sat, 08 Jul 2000 07:57:04 +0000 |
| Subject: | Re: Display all data from two tables with MySQL query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5514@lists.php.net to get a copy of this message | ||
At 18:03 07.07.00 -0600, you wrote:
I want to output all data from two different tables in the same database but it doesn't seem to be working: Is there something special I have to do? I am able to get the output from one database but not both. databaser name is musicdb tables are: albums, songs $query = "SELECT * FROM albums songs ORDER by Artist";$query="select a.albumid, a.album, a.artist, b.genre from album a, songs c order by a.artist"; should work
$result = mysql_db_query("musicdb", $query);
if ($result) {
echo "Found these entries in the database:<ul>";
while ($r = mysql_fetch_array($result)) {
$AlbumID = $r[0];
$Album = $r[1]; /* you are reading from an array so use the position within */
$Artist = $r[2];
$gengre= $r[3];
<TR><TD> <? echo "$AlbumID"; ?></TD> <TD> <? echo "$Album"; ?></TD> <TD> <? echo "$Artist"; ?></TD> <TD> <? echo "$Genre"; ?></TD>