Forum Moderators: coopster
That is the problem. The DEBUG I have set up shows me that I am getting the song and album data correctly from the db, it just shows that both of the arrays are identified by the number zero and are then being lumped together. The album that is fetched second is the one whose songs are shown for both albums.
<?php
if(isset($artist)) {$query = 'SELECT DISTINCT album, picture FROM `songlist` WHERE artist = "'.rawurldecode($artist).'" ORDER BY album ASC';
$database->setQuery($query);
$album_name = $database->LoadResultArray(0);
$album_picture = $database->LoadResultArray(1);
print_r($album_name);$this->assignRef( 'album_name', $album_name );
$this->assignRef( 'album_picture', $album_picture );//Cycle through albums and get songlist
//Find number of albums
$query = 'SELECT COUNT(DISTINCT album) as num FROM `songlist` WHERE artist = "'.rawurldecode($artist).'" ORDER BY album ASC';
$database->setQuery($query);
$numalbums = $database->LoadObject();for ($x = 0, $n = $numalbums->num; $x < $n; $x++)
{
$query = 'SELECT title, ID FROM songlist WHERE artist = "'.rawurldecode($artist).'" AND album = "'.$this->album_name[$x].'" ORDER BY title ASC';
$database->setQuery($query);
$songs = $database->LoadResultArray(0);
$songIDs = $database->LoadResultArray(1);
//DEBUG
print_r($songs);
echo '<br /><br />';
$this->assignRef( 'songs', $songs );
$this->assignRef( 'songIDs', $songIDs );
}
}
?>
<?php
$h = 0;
for ($j=0, $y=count( $this->album_name ); $j < $y; $j++)
{
$row =& $this->album_name[$j];
$row2 =& $this->album_picture[$j];$script = 'window.addEvent(\'domready\', function(){ ';
$script .= 'var mySlide'.$j.' = new Fx.Slide(\'slide'.$j.'\'); ';
$script .= 'mySlide'.$j.'.hide(); ';
$script .= ' $(\'toggle'.$j.'\').addEvent(\'mousedown\', function(e){ e = new Event(e); mySlide'.$j.'.toggle(); e.stop(); }); }); ';
$document->addScriptDeclaration( $script );
//Find tracklist for albumecho '
<tr>
<td width="9%" valign="center">'; if(file_exists('components/com_radio/albumcovers/'.$dj.'/'.$row2)) { echo '<img src="components/com_radio/includes/phpThumb/phpThumb.php?src=../../albumcovers/'.$dj.'/'.$row2.'&w=35" />'; } else { echo '<img width="35px" height="35px">'; } echo '</td><td width="85%" valign="middle"> '.$row.'</td><td width="1%"></td><td width="5%" valign="middle"><a id="toggle'.$j.'" name="toggle'.$j.'" class="slideTitleLink"><span class="slideTitle">[+/-]</span></a>
<tr><td colspan="3">
<div id="slide'.$j.'" class="slideBox" style="margin-left:50px;">
<table border="0">
';for ($r=0, $q=count( $this->songs ); $r < $q; $r++)
{
echo '<tr><td width="100%"><a href="index.php?option=com_radio&view=songinfo&dj='.$dj.'&songID='.$this->songIDs[$r].'">'.$this->songs[$r].'</a></td><!--<td width="1%"></td><td width="3%">»</td>--></tr>';
}echo ' </table> </div>
</td></tr>
</td>
</tr>';
}
?><?php }?>
This is what I get from the DEBUG part of my script:
Array ( [0] => A Change Of Pace [1] => An Offer You Can't Refuse ) Array ( [0] => A Song the World Can Sing Out Loud [1] => How to Rape a Country [2] => I Wanna Be Your Rock & Roll [3] => I'm Alive [4] => Prepare the Masses [5] => Recipe for Disaster [6] => Safe and Sound In Phone Lines [7] => Shoot from the Hip [8] => Take Care [9] => War In Your Bedroom [10] => Weekend Warriors [11] => White Lines and Lipstick )Array ( [0] => A Farewell To Friendship [1] => Asleep At The Wheel [2] => Chippie [3] => Death Do Us Part [4] => December [5] => Every Second [6] => Goodbye For Now [7] => Home Is Where The Heart Is [8] => Know One Knows [9] => Loose Lips Sink Ships [10] => Queen Of Hearts )
I think that the fact that both arrays are Array [0] is the problem. Would that make sense?
Can anyone identify what the problem is and how I might be able to fix it?
Thank you very much.
Hess Smith
If it if involves any sort of pagination, I would look at redesigning the query to return a single result set of data.