mazchaz Posted October 20, 2007 Share Posted October 20, 2007 Hey guys, Im not expert on PHP, infact i dont really know how to use it but I have manged to set up the following: http://www.hothouseradio.com/test1/Index.html as you can see under coming up it has to songs numbered 1 2 3.... but on the recently played it just repeats the number :S I dont know why, here is the code. Please help <html><META HTTP-EQUIV="REFRESH" CONTENT="80"></html> <? $usr = "hothouse_test"; $pwd = "********"; $db = "hothouse_SAMDB"; $host = "66.45.250.50"; $sqlCon = mysql_connect($host, $usr, $pwd); if (!$sqlCon) { echo("ERROR: " . mysql_error() . "\n"); } // CURRENTLY PLAYING $curPlaySQL = "SELECT artist,title,album,website,buycd,date_played FROM historylist ORDER BY date_played DESC LIMIT 1"; $curPlay = mysql_db_query($db, $curPlaySQL, $sqlCon); $curPlayRow = mysql_fetch_array($curPlay); // COMING UP $comingUpSQL = "SELECT queuelist.songID,queuelist.ID,queuelist.requestID,songlist.ID,songlist.artist,songlist.title FROM queuelist JOIN songlist ON queuelist.songID = songlist.ID ORDER BY queuelist.ID ASC LIMIT 5"; $comingUp = mysql_db_query($db, $comingUpSQL, $sqlCon); $upCnt = 1; // PREVIOUS PLAYED $recentPlayedSQL = "SELECT artist,title,date_played FROM historylist ORDER BY date_played DESC LIMIT 2"; $recentPlayed = mysql_db_query($db, $recentPlayedSQL, $sqlCon); $recentPlayedRow = mysql_fetch_array($recentPlayed); $recCnt = 1; ?> <html> <head> <title></title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, sans-serif; } .style2 {font-family:Verdana, Arial, sans-serif; font-weight:bolder; } .style3 {font-family:Verdana, Arial, sans-serif; text-decoration:underline} --> </style> </head> <body> <span class="style3"><marquee><? echo("Currently Playing: ".$curPlayRow['artist']." - ".$curPlayRow['title']); ?></marquee></span> <p><span class="style2">Coming Up</span><br><span class="style1"> <? while ($comingUpRow = mysql_fetch_array($comingUp)) { echo($upCnt.". ".$comingUpRow['artist']." - ".$comingUpRow['title']."<br>"); $upCnt = $upCnt+1; }?> </p> </span> <p><span class="style2">Recently Played</span><br><span class="style1"> <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']."<br>"); $recCnt = $recCnt+4; }?> <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo("<table><tr><td width=120><b>".$recentPlayedRow['artist']."</b></td><td width=120 align=left><em>".$recentPlayedRow['title']."</em></td><td width=140 align=left>".$recentPlayedRow['album']."</td><td width=120 align=left>".$recentPlayedRow['date_played']."</td></tr></table><h r>"); $recCnt = $recCnt+4; }?> </p> </span> </body> </html> <? mysql_close($sqlCon); ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/ Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 1. Don't use caps in title. 2. Be more generic in your request. 3. Use code tags around code examples. 4. Use full open tags so it does the syntax highlighting. Repost your code with the following in mind (the last 2) and I will take a look at it. Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374006 Share on other sites More sharing options...
mazchaz Posted October 20, 2007 Author Share Posted October 20, 2007 1. Don't use caps in title. 2. Be more generic in your request. 3. Use code tags around code examples. 4. Use full open tags so it does the syntax highlighting. Sorry,I dont really understand what you mean in the last two ?? im only 15 can you explain more what you want me to do and I will try Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374010 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 Fix this. <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']." "); $recCnt = $recCnt+4; }?> Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374024 Share on other sites More sharing options...
mazchaz Posted October 20, 2007 Author Share Posted October 20, 2007 Hello, Thanks for the help but that didn't work <html><META HTTP-EQUIV="REFRESH" CONTENT="80"></html> <? $usr = "hothouse_test"; $pwd = "test"; $db = "hothouse_SAMDB"; $host = "66.45.250.50"; $sqlCon = mysql_connect($host, $usr, $pwd); if (!$sqlCon) { echo("ERROR: " . mysql_error() . "\n"); } // CURRENTLY PLAYING $curPlaySQL = "SELECT artist,title,album,website,buycd,date_played FROM historylist ORDER BY date_played DESC LIMIT 1"; $curPlay = mysql_db_query($db, $curPlaySQL, $sqlCon); $curPlayRow = mysql_fetch_array($curPlay); // COMING UP $comingUpSQL = "SELECT queuelist.songID,queuelist.ID,queuelist.requestID,songlist.ID,songlist.artist,songlist.title FROM queuelist JOIN songlist ON queuelist.songID = songlist.ID ORDER BY queuelist.ID ASC LIMIT 5"; $comingUp = mysql_db_query($db, $comingUpSQL, $sqlCon); $upCnt = 1; // PREVIOUS PLAYED $recentPlayedSQL = "SELECT artist,title,date_played FROM historylist ORDER BY date_played DESC LIMIT 6"; $recentPlayed = mysql_db_query($db, $recentPlayedSQL, $sqlCon); $recentPlayedRow = mysql_fetch_array($recentPlayed); $recCnt = 1; ?> <html> <head> <title></title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, sans-serif; } .style2 {font-family:Verdana, Arial, sans-serif; font-weight:bolder; } .style3 {font-family:Verdana, Arial, sans-serif; text-decoration:underline} --> </style> </head> <body> <span class="style3"><marquee><? echo("Currently Playing: ".$curPlayRow['artist']." - ".$curPlayRow['title']); ?></marquee></span> <p><span class="style2">Coming Up</span><br><span class="style1"> <? while ($comingUpRow = mysql_fetch_array($comingUp)) { echo($upCnt.". ".$comingUpRow['artist']." - ".$comingUpRow['title']."<br>"); $upCnt = $upCnt+1; }?> </p> </span> <p><span class="style2">Recently Played</span><br><span class="style1"> <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']."<br>"); $recCnt = $recCnt+4; }?> <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']." "); $recCnt = $recCnt+4; }?> </p> </span> </body> </html> <? mysql_close($sqlCon); ?> you can see what i have changed in bold but it made no difference. Any extra help would be helpful Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374035 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 <? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) { echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']." "); $recCnt = $recCnt+4; }?> What did not work? Check your variable names!!! Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374037 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 You are echoing $upCnt which will always be equal to 6 because of its value that was assigned in the coming up while statement. Or am I wrong? What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374044 Share on other sites More sharing options...
mazchaz Posted October 20, 2007 Author Share Posted October 20, 2007 I'm just trying to get the recently played list go in number order (1,2,3,4,5) but at the moment it just goes 6,6,6,6,6 sorry I'm not very good with PHP Cheers Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374103 Share on other sites More sharing options...
igor berger Posted October 20, 2007 Share Posted October 20, 2007 Okay this needs to be a unix time stamp date_played then you can use date() function to convert it to date but you can compare the time stamp to see which one is greater and that will be last played... After you play the song update the date_played with a system date unix stamp... Quote Link to comment https://forums.phpfreaks.com/topic/74084-trouble-with-this-code-trying-to-get-songs-numbered-1-to-5/#findComment-374107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.