I have 2 tables, one containing events information (showSearch) and another containing venue information (venueDesc). There's a section on my website that needs to display the up coming events (which list date, time, band, and venue) and if the venue for that event has additional info then the venue name from the events table needs to link to a page that displays the venue information from the venue table.
My question is, how do I display data from the showSearch table that ties in with the venueDesc table depending on whether the information exists or not?
Here's the code that I've come up with but does not work:
$result = $sql->Select("SELECT * from showSearch, venueDesc ORDER BY date asc, ");
for ($i=0; $i < 14; $i++) {
$id = $result[$i]['id'];
$artist = $result[$i]['artist'];
$venue = $result[$i]['venue'];
$info = $result[$i]['info'];
$date = $result[$i]['date'];
$venuename = $result[$i]['venuename'];
$time = $result[$i]['time'];
$dooder = sql_to_human_date($time,'g:i');
if($venuename == $venue)
{ // make the venue clickable by formatting it as HTML link
$venue = "<a href=\"venues.php?venuename=$venuename\">$venue</a>";
}
When I echo $venue it displays each event the amount of rows I have in the venueDesc table. So if I have 5 rows in the venueDesc table then each event will be displayed 5 times.
Can anyone help me with this?
Thanks!