I am working with a webpage which I am changing and I am going to try to explain what I am doing without posting all the PHP code, just the segment I need help on is the goal
I have two Shoutcast servers which we are pulling stats from in XML. We have a "class" that parses the XML and gives us PHP variables which we have defined in the document. This works in our current webpage, http://radioteal.no-ip.com. The problem is the servers are listed linear-ly instead of side by side like my new rendition calls for (http://radioteal.no-ip.com/miketest/concept.php). This is a dummy mock up of what we want. We are re-using our code from the current page and the problem is the current implenmentation just "stacks" the tables... not what we are going for. My idea for a solution is to use an array to store the tables for the number of SC servers. Since the code can be modified to accept any number of servers (just by making new instances of the "class") it would be nice to store the tables that house the data in an array (perhaps called $svrTable) where $svrTable[0] would be the table for $shoutcast[0] and $svrTable[1] would be the table for $shoutcast[1]... etc.
I am not sure how to setup the array as someone else did the class file for Shoutcast servers.
This is where the song history ( a part of the table we want) is produced, thanks for the earlier help getting every other row colorized
Code: Select all
if (is_array($history)) {
for ($j=0;$j<sizeof($history);$j++) {
$songї$j] = $historyї$j]ї"title"];
//echo $songї$j].'<br>';
$bgColor = ($j % 2) ? '#00CCCC' : '#FFFFFF';
echo '<tr><td bgcolor="'.$bgColor.'">'.$songї$j].'</td></tr>';
}Code: Select all
for($i=0; $i<count($shoutcast); $i++) {
if ($shoutcastї$i]->openstats()) {
// format the output to suit your particular needs
if ($shoutcastї$i]->GetStreamStatus()) {
//new code begin
$scname = $shoutcastї$i]->GetServerTitle();
$currentSong = $shoutcastї$i]->GetCurrentSongTitle();
$bitRate = $shoutcastї$i]->GetBitRate();
$listeners = $shoutcastї$i]->GetCurrentListenersCount();
$scport = $shoutcastї$i]->port;
$servip = $shoutcastї$i]->host;
$history = $shoutcastї$i]->GetSongHistory();
$genre = $shoutcastї$i]->GetServerGenre();
$peakListeners = $shoutcastї$i]->GetPeakListenersCount();
echo '
<table width="100%" border="0">
<tr>
<td width="45%"><b>'.$scname.'</b> ('.$bitRate.' Bit) Stream <br>
<font color="#FF0000">Genre:</font> '.$genre.'
</td>
<td width="20%" rowspan="2" align="center"><p>Current Listners: <font size="+1" color="#FF0000">'.$listeners.'</font></p>
<a href="http://'.$servip.':'.$scport.'/listen.pls"><img src="images/tealspeaker.jpg" alt="Listen" border="0" align="middle">Listen</a></td>
<td width="35%" rowspan="2">
<p><b>Recently Played:</b></p>
<table>';
if (is_array($history)) {
for ($j=0;$j<sizeof($history);$j++) {
$songї$j] = $historyї$j]ї"title"];
//echo $songї$j].'<br>';
$bgColor = ($j % 2) ? '#00CCCC' : '#FFFFFF';
echo '<tr><td bgcolor="'.$bgColor.'">'.$songї$j].'</td></tr>';
}There are actually 10 rows and 1 column and the actual table would have these two (in this case) nested inside of the concept.php area where you see the server name etc.
I am not sure how to make this array is the problem.
Thanks for the help.