Jump to content

Combine: two tables


damju87
 Share

Recommended Posts

1st code is the album. It works when by clicking on a album which will bring up this:

//initialize some vars$albumID = '';$album = '';//$songAlbum = $albumName; //check what photo we are looking forif(isset($_GET['id'])){	$albumID = mysql_real_escape_string($_GET['id']);	//get the photo	$sql = mysql_query("SELECT * FROM albums WHERE albumID='$albumID' LIMIT 1");	while($row = mysql_fetch_array($sql)){		$albumName = $row['albumTitle'];  $albumpic = $row['albumpic'];  $performer = $row['performer'];  $albumtype = $row['type'];  $titletrack = $row['titletrack'];  $genre = $row['genre'];  $releasedate = $row['releasedate'];  $distributor = $row['distributor'];  $albumtest .= ' <div id="content">	  <div id="name">' . $albumName . '</div>	  <div id="photo">	  <img src="../images/albums/album_th/' . $albumpic . '.jpg" />	  </div>	  <ul class="clearfix">	  <li>	  <span class="title">Performer (s)</span>	  <span class="data">' . $performer . '</span>	  </li><li>	  <span class="title">Type</span>	  <span class="data">' . $albumtype . '</span>	  </li><li>	  <span class="title">Title Track</span>	  <span class="data">' . $titletrack . '</span>	  </li><li>	  <span class="title">Genre</span>	  <span class="data">' . $genre . '</span>	  </li><li>	  <span class="title">Release Date</span>	  <span class="data">' . $releasedate . '</span>	  </li><li>	  <span class="title">Distributor</span>	  <span class="data">' . $distributor . '</span>	  </li></ul>	  	  </div>	  ';	}}else{	$albumtest = "There are no available albums at this time!";}

Second is the songs. It finds all the tracks from the album and places them in order.

// Get all the data from the "example" table$result = mysql_query("SELECT * FROM songs WHERE album='Agia 1st Album' ORDER BY tracknum")or die(mysql_error());echo "<ol>";// keeps getting the next row until there are no more to getwhile($row = mysql_fetch_array( $result )) {// Print out the contents of each row into a tableecho "<li>";echo $row['songTitle'];echo "</li>";}echo "</ol>";

My problem is combining them into one. I want when the album is selected, the page is displayed with album information and tracklist.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...