Jump to content

Problem with links in a loop


wee493

Recommended Posts

I'm creating a stat-type page for last.fm. Using a foreach loop I'm returning the data from the last.fm api. I'm linking artist names to the appropriate artist page and so on with songs & albums. The only problem is that in two of the three loops only the links from the first result are working. The <a hef is displayed when viewing the html source, I'm stumped. You can see for yourself here... http://wee493.com/lastfm/?user=josho493 (Feel free to plugin your own last.fm username here if you would like :P)

 

Here's one of the loops that is having the problem.

<?PHP
$top_tracks = $lastfm->user_getTopTracks("user=".$user);

foreach ($top_tracks['lfm']['toptracks']['track'] as $trk){
$rank = $trk['attr']['rank'];
$name = $trk['name']['value'];
$playcount = $trk['playcount']['value'];
$url = $trk['url']['value'];
$artist = $trk['artist']['name']['value'];
$artist_link = $trk['artist']['url']['value'];

if($rank <= '10'){
?>


<div class="top">
    	<div class="rank">
        	<?PHP echo $rank; ?>
        </div>
        <div class="top-song-info">
        	<div class="title">
            	<a href="<?PHP echo $url; ?>" target="_blank"><?PHP echo $name; ?></a>
            </div>
            
            <div class="artist-info">
            	<span class="artist"><a href="<?PHP echo $artist_link; ?>" target="_blank"><?PHP echo $artist; ?></a></span>
                <span class="date"><?PHP echo $playcount; ?> Plays</span>
            </div>
            
            
        </div>
    </div>


<?PHP
} /* end if */ } // end foreach

 

Any help is appreciated! Thanks :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.