Jump to content

Trouble with this code, trying to get songs numbered 1 to 5


Recommended Posts

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

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.

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

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

<? while ($recentPlayedRow = mysql_fetch_array($recentPlayed)) {

echo($upCnt.". ".$recentPlayedRow['artist']." - ".$recentPlayedRow['title']."

");

$recCnt = $recCnt+4;

}?>

 

What did not work?

 

Check your variable names!!!

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...

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.