Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Problems with display content from a recordset and repeat region.

Participant ,
Mar 04, 2008 Mar 04, 2008

Copy link to clipboard

Copied

I've got what I would think is a simple PHP page that just lists all the artists for a record label. Page works fine but now my problem is each artist is to link to another page listing all their albums and that's where my problem lies. Seems to completely ignore any of my link commands and instead just lists the first album in the list 11 times instead of all the albums related to an artist id.

Here's the main page:
http://www.basinstreetrecords.com/prss/index.php
Code: http://www.basinstreetrecords.com/prss/index.txt

and here's the link page:
http://www.basinstreetrecords.com/prss/albums.php?artist_id=4
Code: http://www.basinstreetrecords.com/prss/albums.txt
TOPICS
Server side applications

Views

378
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2008 Mar 04, 2008

Copy link to clipboard

Copied

On Wed, 5 Mar 2008 02:08:21 +0000 (UTC), "databell"
<webforumsuser@macromedia.com> wrote:

> Code: http://www.basinstreetrecords.com/prss/albums.txt

In this page, change this:

<?php do { ?>
<p><?php echo $row_rsPressAlbums['downloads_album']; ?></p>
<?php } while ($row_rsPressArtists=mysql_fetch_assoc($rsPressArtists));
?></td>

To this:

<?php do { ?>
<p><?php echo $row_rsPressAlbums['downloads_album']; ?></p>
<?php } while ($row_rsPressArtists=mysql_fetch_assoc($rsPressAlbums));
?></td>


Gary

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 05, 2008 Mar 05, 2008

Copy link to clipboard

Copied

That didn't work. If you now go to http://www.basinstreetrecords.com/prss/albums.php?artist_id=4 you'll just see the first name in the artist_id and then the first album over and over again over 20 times. Not at all what I want.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2008 Mar 05, 2008

Copy link to clipboard

Copied

On Wed, 5 Mar 2008 19:57:16 +0000 (UTC), "databell"
<webforumsuser@macromedia.com> wrote:

>That didn't work. If you now go to
> http://www.basinstreetrecords.com/prss/albums.php?artist_id=4 you'll just see
>the first name in the artist_id and then the first album over and over again
>over 20 times. Not at all what I want.

Oops. Sorry, I missed changing it in the second place it needed to be
changed. Here is the code I originally suggested:

<?php do { ?>
<p><?php echo $row_rsPressAlbums['downloads_album']; ?></p>
<?php } while ($row_rsPressArtists=mysql_fetch_assoc($rsPressAlbums));
?></td>

Change that to:

<?php do { ?>
<p><?php echo $row_rsPressAlbums['downloads_album']; ?></p>
<?php } while ($row_rsPressAlbums=mysql_fetch_assoc($rsPressAlbums));
?></td>

Gary

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 05, 2008 Mar 05, 2008

Copy link to clipboard

Copied

Yea, definitely an improvement but not completely there. It's now listing all the albums instead of just the ones that correspond to a certain artist's ID aka artist_id.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

On Thu, 6 Mar 2008 06:58:19 +0000 (UTC), "databell"
<webforumsuser@macromedia.com> wrote:

>Yea, definitely an improvement but not completely there. It's now
>listing all the albums instead of just the ones that correspond to a
>certain artist's ID aka artist_id.

Missed that completely. You'll need to change your SELECT in the albums
query:

$query_rsPressAlbums = "SELECT * FROM downloadsAlbums";

You'll need to add a WHERE clause to it to select only the ablums for
that artist. I assume your downloadsAlbums table has a field for the
artist ID and I'm guessing the field name is artist_id as you mentioned
above. IF that's not the field name, correct that when you change the
above line to:

$query_rsPressAlbums = "SELECT * FROM downloadsAlbums".
" WHERE artist_id=$_GET[artist_id]";

Your artists query also needs a WHERE clause to keep it from just
grabbing the first artist every time. Change this:

$query_rsPressArtists = "SELECT artistID, artistName FROM forumArtists";

To this:

$query_rsPressArtists = "SELECT artistID, artistName FROM forumArtists".
" WHERE artistID=$_GET[artist_id]";

Gary

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 07, 2008 Mar 07, 2008

Copy link to clipboard

Copied

I finally figured it out and only needed one recordset instead of two. I deleted rsPressArtists and kept rsPressAlbums and to that I added this:

SELECT *
FROM forumArtists, downloadsAlbums
WHERE forumArtists.artistID = downloadsAlbums.downloads_artist AND downloadsAlbums.downloads_artist = colname

Because I wanted to keep row names in the tables unique as I've had problems before like that.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 07, 2008 Mar 07, 2008

Copy link to clipboard

Copied

LATEST
Well, one problem solved but as a result of all that I had to add the extra table to the index page that lists all the artists' names. Now that's repeat the entire list over and over for each artistID. Here's the example:

http://www.basinstreetrecords.com/prss/index2.php

and the code:

http://www.basinstreetrecords.com/prss/index.txt

I checked it to the prior code Gary posted awhile back and the php do looks right so why is it repeating the list over and over?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines