Location: PHPKode > projects > Webbased Music Jukebox > wmj-0.1-devel/index.php
<?
include "config.php";
include "function.php";

$connection=connectdb();

if ($next_x){
	skipthebox();
}

if ($delete){
	$result=mysql_query("delete from playlist where filename='".urldecode($delete)."'", $connection);
    if (!$result){
        echo "Did not work";
    }
}
//query prefs for the current file that is playing 
$result=mysql_query("select files.counter, prefs.currentplay from prefs, files where files.filename=prefs.currentplay", $connection);
$rowprefs=mysql_fetch_array($result);

// Begin HTML output.

echo '<meta http-equiv="refresh" content="15"; URL=index.php charset=iso-8859-1">';
html_header();
//echo "<p>&nbsp;</p>";
//echo ;
?>
      <form name="form" method="post" action="index.php">
<? start_maintable(); ?>

			<table width=\"100%\" cellspacing=\"0\">
			  <tr>
			    <td align=\"right\"><? echo "<img src=\"".$skindir.$skin."/current.jpg\">"; ?></td>
				<td align=\"left\"><? echo "<b>".$rowprefs[currentplay]."</b> played <b>".$rowprefs[counter]."</b> times randomly"; ?></td>
			  </tr>
			</table>
			<br>
  			  <input type="image" src="<? echo $skindir.$skin; ?>/button-next.jpg" name="next">
			<br><br>
			  <!-- playlist table -->
		      <table class="playlist" width="100%" cellspacing="<? echo $skininfo['cellspacing']['playlist']; ?>">
                <tr>
                  <th class="playlist" width="25%"><img src="<? echo $skindir.$skin; ?>/header-artist.jpg"></th>
                  <th class="playlist" width="25%"><img src="<? echo $skindir.$skin; ?>/header-song.jpg"></th>
                  <th class="playlist" width="25%"><img src="<? echo $skindir.$skin; ?>/header-album.jpg"></th>
                  <th class="playlist" width="25%"><img src="<? echo $skindir.$skin; ?>/header-duration.jpg"></th>
				  <th class="playlist">&nbsp;</th>
                </tr>
<?
//select the stuff from playlist and files table
$queryfirst="select filename from playlist order by id";
$resultfirst=mysql_query($queryfirst, $connection);

while ($rowfirst=mysql_fetch_array($resultfirst)){

    $query="select * from files where filename='".addslashes($rowfirst[filename])."'";
	$result=mysql_query($query, $connection);
	while ($row=mysql_fetch_array($result)){
				
		//define the empty array items.
		if (!$row[album]){$album="unknown album";} else { $album=($row[album]); }
		if (!$row[title]){$title="unknown title";} else { $title=($row[title]); }
		if (!$row[artist]){$artist="unknown artist";} else { $artist=($row[artist]); }

		//calc the plattime.
		// YES, IT CAN BE DONE IN 1 LINE =)
		$playtime=floor($row[playtime]/60).":".str_pad($row[playtime]%60, 2, "0", STR_PAD_LEFT);

		/*calculate the playtime
		$time1=($row[playtime]/60);
		$timefloor=floor($time1);
		$time=($row[playtime] % 60); 
		$time2=str_pad($time,2,"0",STR_PAD_LEFT);
		$tijd="$timefloor:$time2";*/


		//print the current playlist.
		echo "  <tr>".
            "    <td class=\"playlist\" width=\"25%\" align=\"center\">".stripslashes($artist)."</td>\n".
            "    <td class=\"playlist\" width=\"25%\" align=\"center\">".stripslashes($title)."</td>\n".
            "    <td class=\"playlist\" width=\"25%\" align=\"center\">".stripslashes($album)."</td>\n".
            "    <td class=\"playlist\" width=\"25%\" align=\"center\">".$playtime." min</td>\n".
            "    <td class=\"playlist\" align=\"center\"><a href=\"index.php?delete=".urlencode($rowfirst[filename])."\"><img src=\"".$skindir.$skin."/button-playlistdel.jpg\" border=\"0\"></td>\n".
            "  </tr>";
	}
}
?>
			  </table>
			  <!-- /playlist table -->
<? end_maintable(); ?>
	  </form>

<?
html_footer()
?>
Return current item: Webbased Music Jukebox