Hey all.
I have a table where a concertID, setID and venueID is stored. Now when i output i seem to be going about it a very clunky way as there could be more then one venueName. This is to reflect changes of a venue's name over the course of the years.
so an entry could be like:
1 1 3
1 1 5
there is the same concert and set it's just associated with 2 venue names. It could be more then 2 and there could be only 1 name.
I'm printing out all the concerts on a page but i don't want a concert repeated multiple times with just a different venueName. I want that alternate venueName attached to the first printing of that specific concert on the page.
I do have a working script but it seems very blah the way i tried to figure out if the next thing i go was the same show with an alternate name or not and then work it into the table structure.
here is a simple script i was just playing with.
PHP Code:
$DBName = "dmb_concerts";
$TableName1 = "concert_taper_source";
$TableName2 = "concert_set_venue";
$TableName3 = "concert_info";
$TableName4 = "taper_info";
$TableName5 = "source_info";
$TableName6 = "venue_info";
$TableName7 = "set_info";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "SELECT * FROM (($TableName3
left join $TableName2 ON $TableName3.concertID = $TableName2.concertID)
left join $TableName7 ON $TableName2.setID = $TableName7.setID)
left join $TableName6 ON $TableName2.venueID = $TableName6.venueID";
$Result = mysql_db_query ($DBName, $Query, $Link);
$temp1 = 123;
$temp2 = 456;
print("<table align='center' border='1'>");
while ($row = mysql_fetch_array($Result))
{
if($temp1 != $row[concertID])
{
if($temp2 == 1)
{
print("</tr>");
$temp2 = 123;
}
print("
<tr>
<td>$row[date]</td>
<td>$row[artist]</td>
<td>$row[venueName]</td>
");
$temp1 = $row[concertID];
$temp2 = 1;
}
else
print("<td>$row[venueName]</td>");
}
print("</table>");
as you can see it's very blah the way i tried to see if the next thing i got was the same concert with an alternate name. I used temp vars and stuff.
Is there a better way to accomplish this?? Bad database layout?
Thanks!