PDA

View Full Version : Need some help, probably simple to do.


mr_badger
12-17-2007, 12:27 AM
I have a site that has an index page with a list of music artists, when you click on an artist it takes you to artistdetail.php with the title of the album, artwork and tracklisting, this all works fine but I want to have on this page a section that has the artists other albums that this artist has done. You then click on another album and that page opens, I just can't seem to figure out how to make this work.

My table structure is this:
Table 1 is called Album and has - album_id, artist_id, album_name, album_year, album_image, album_tracklist

Table 2 is called artist and has - album_id, artist_id, artist

davidj
12-17-2007, 06:49 AM
hand coded or dreamweaver coded?

mr_badger
12-17-2007, 01:30 PM
dreamweaver coded, I'am using the server behaviours

davidj
12-17-2007, 01:35 PM
hi mr badger

i cant help with this. Sorry. This is a hand coding forum

If you ever want to develop your programming skills let me know

will move this post to a forum where you may find assistance

edbr
12-18-2007, 01:50 AM
post some code

mr_badger
12-18-2007, 01:28 PM
<?php require_once('Connections/albums.php'); ?>
<?php
$colname_getAlbumDetails = "-1";
if (isset($_GET['album_id'])) {
$colname_getAlbumDetails = (get_magic_quotes_gpc()) ? $_GET['album_id'] : addslashes($_GET['album_id']);
}
mysql_select_db($database_albums, $albums);
$query_getAlbumDetails = sprintf("SELECT * FROM album WHERE album.album_id = %s ", $colname_getAlbumDetails);
$getAlbumDetails = mysql_query($query_getAlbumDetails, $albums) or die(mysql_error());
$row_getAlbumDetails = mysql_fetch_assoc($getAlbumDetails);
$totalRows_getAlbumDetails = mysql_num_rows($getAlbumDetails);

mysql_select_db($database_albums, $albums);
$query_getOtherAlbums = "SELECT artist.artist_id, album.album_id, album.artist_id, album.album_image FROM artist, album WHERE album.album_id = artist.artist_id ORDER BY album.album_image";
$getOtherAlbums = mysql_query($query_getOtherAlbums, $albums) or die(mysql_error());
$row_getOtherAlbums = mysql_fetch_assoc($getOtherAlbums);
$totalRows_getOtherAlbums = mysql_num_rows($getOtherAlbums);
?>

<body>
<div id="album_detail">
<p>Artist - <?php echo $row_getAlbumDetails['artist_id']; ?><br />
<br />
Album - <?php echo $row_getAlbumDetails['album_name']; ?><br />
<br />
Released - <?php echo $row_getAlbumDetails['album_year']; ?><br />
<br />
<img src="album_artwork/<?php echo $row_getAlbumDetails['album_image']; ?>" border="1" /></p>
<p>Tracklist:<br />
<?php echo nl2br ($row_getAlbumDetails['album_tracklist']); ?></p>
<p>Related Albums:</p>

<?php do { ?>
<table width="50" border="0" cellspacing="5" cellpadding="2">
<tr>
<th scope="col"><img src="album_artwork/<?php echo $row_getOtherAlbums['album_image']; ?>" /></th>
</tr>
</table>
<?php } while ($row_getOtherAlbums = mysql_fetch_assoc($getOtherAlbums)); ?><p>&nbsp; </p>
</div>
</body>
</html>
<?php
mysql_free_result($getAlbumDetails);

mysql_free_result($getOtherAlbums);
?>
Hope this helps, this code is on the artistdetail.php page.

edbr
12-19-2007, 02:04 AM
this is a really good example of Davids desire to educate us into spitting out the dreamweaver dummy and learn to code php.

I have a learner plate on myself but as I see it :

$_GET['album_id']is your selector from a form. this brings your first records

so your second recordset will have to select where artist_id = $row_getAlbumDetails['artist_id'].

The do loop will fetch all records from that artist. Thats the logic as I see it anyway

davidj
12-19-2007, 06:53 AM
dont think that will help him as you have used code to explain a solution to someone who cant code
you have to write the solution for him
you have to supply an extension or point him in the direction of onemr badger

you now can see why you should learn to code

edbr
12-19-2007, 08:13 AM
I don't disagree david, definitely better.

lux
12-19-2007, 09:28 AM
hey mr_badger,

if you're not looking to learn to hand code the site then it's worth while learning how you properly use the software you've bought.

this is a link to a dreamweaver blog tutorial. if you go through it and create the blog you will learn a great deal about the software you have bought and its capabilities.

whilst completing the tutorial think about how you can implement what you have learned into your own site.

linky: http://www.adobe.com/devnet/dreamweaver/articles/php_blog1.html

mr_badger
12-19-2007, 02:38 PM
thanks for the reply, I will do the blog tutorial. I have tried to do the hand coding but it's hard and just found doing it all with dreamweaver server behaviors easier to understand.

davidj
12-19-2007, 02:41 PM
I have tried to do the hand coding but it's hard and just found doing it all with dreamweaver server behaviors easier to understand


not when you get yourself in a pickle like now

mr_badger
12-29-2007, 06:20 PM
ok I have done the blog tutorial which works fine but I'm still having trouble with displaying the artist albums.

I have had it to the point where it will display the correct album but only one album and no others.
I have also now got it to the point where I have created a recordset called rsAlbums which when I test it in the simple dialog it shows all the albums produced for the artist but when I create the recorset it doesn't display anything?

This is my recordset
SELECT *
FROM artist_album
WHERE idartist_album = colname
ORDER BY id_album ASCcolname = idartist_album

my mysql tables are:
[artist album] with fields - id_album, idgenre_album, idartist_album, description_album, tracklist_album, artwork_album, released-album.

[artist_artist] with fields - id_artist, idgenre_artist, artist, description_artist, artist_image, text_artist

[artist_genre] with fields - id_genre, title_genre, description_genre

Hope someone can help me with this.

edbr
12-31-2007, 01:28 AM
how is the recorset choosing the criteria? in your filter are you choosing the form submission?

mr_badger
12-31-2007, 02:13 PM
no, by url parameter.

edbr
01-02-2008, 01:32 AM
then your second record set needs $_GET['album_id'] the same as the first recordset

mr_badger
01-03-2008, 04:49 PM
thankyou for replying, I have done what said and when I do a test in the recordset panel is says please provide a test value so I type in an artist_id like 12 and press test it works and shows all the albums that artist has produced, this is what I want.

So i created the recordset and when I inserted the album_description from the bindings panel onto the page and tested the page in my browser it is just blank where the album_description should be. This is what is confusing me?

edbr
01-07-2008, 04:35 AM
it is not picking up the value then . your first set is choosing by $_GET['album_id']. you have to supply a value for your second set to use artist name for example

mr_badger
01-07-2008, 10:54 AM
I have 2 recordsets on the page.
I have rs_Artist with a $_GET value of id_artist and and second recordset rs_Albums with a $_GET value of id_album.
Still can't get the rs_Albums to work.

edbr
01-08-2008, 01:22 AM
ok sorry i havent been concentrating much ( xmas cheer maybe!)
your first set is selected by url value
$_GET['album_id'your second
"SELECT * FROM artist, album WHERE album.album_id = artist.artist_id "; (shortened for clarity) but firstly does the artist have the same id in both tables?
iwould have thought by artist name would have been better
in any case i would have the 2nd record set select by $row_getAlbumDetails['artist_id'] which is the returned value by the first set.