Re: joining tables
| From: | David Robley | Date: | Sun, 15 Sep 2002 23:30:51 +0000 |
| Subject: | Re: joining tables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21766@lists.php.net to get a copy of this message | ||
In article <WorldClient-F200209141027.AA27090001@weizwaze.ath.cx>,
basza@weizwaze.ath.cx says...
> I have the following code :
> <?
> $sql = "SELECT juke_artists.id, juke_artists.name, juke_tracks.id,
> juke_tracks.ar_id, juke_tracks.name FROM juke_tracks, juke_artists WHERE
> juke_tracks.ar_id = juke_artists.id and juke_tracks.name like '$lyrics%'
> ORDER BY juke_tracks.name";
>
> $lyricnames = mysql_query($sql) or die("Select Failed!");
> while ($lyricname = mysql_fetch_array($lyricnames)) {
> ?>
> <table width="100%" border="0">
> <tr>
> <td><? echo "<b><a href='lyricinfo.php?info=$lyricname
> [juke_tracks.id]'>$lyricname[juke_tracks.name]</a> </b> - By $lyricname
> [juke_artist.name]<br> "; ?></td>
> </tr>
> </table>
> <? } ?>
>
> Being new to php & mysql I have done some reading to get the above
> code, but for some reason it returns nothing. Could someone please
> point out where I might have gone wrong.
>
> Thanks in advance
'Returns nothing' is a little ambiguous - are there no matching records,
or there are matching records that are not being displayed?
To determine if you are finding matching records, you could add a call to
mysql_num_rows after your mysql_query. If the result is > 0 you have
matching records which are not being displayed; a possible reason is that
you are not quoting the fieldnames when trying to echo them:
$lyricname['juke_tracks.name']
You might also find the extract() function handy for assigning the field
values to variable names.
--
David Robley
Temporary Kiwi!
Quod subigo farinam