<html>
<title>Melero Video - Share and watch your videos with friends, family, and everyone you know.</title>
<?php include('config.php');
 include("headertop.php"); 
/////////mySQL Connect////////////////
mysql_connect($dbloc, $dbuser, $dbpass);
mysql_select_db($db); 
if(@$_POST['newplaylist']){
$cat=@$_POST['newplaylist'];
//Create Playlist
$date=date("F j, Y, g:i a");
$userdbname=$_COOKIE['username'].'playlist';
$result = mysql_query("SHOW TABLE STATUS LIKE '$userdbname'");
$row = mysql_fetch_array($result);
$nextid = $row['Auto_increment'];  
$userlist=$_COOKIE['username'].$nextid;
$user=$_COOKIE['username'];
mysql_query("INSERT INTO $userdbname(userid, title, date, views, nextid) VALUES('$user', '$cat', '$date', '0', '$nextid')"); 
mysql_query("CREATE TABLE $userlist( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), userid VARCHAR(100), allgenreid VARCHAR(100))"); 
echo '<center>Playlist Created';
}
echo'<P><br><table width=100%>
<td><font size=6><b>Playlists</b></td>
<td><form action="playlistmore.php" METHOD="post">
<input type=text name=newplaylist>
<input type=submit value="Create">
</form></td>
</td></table>
<table width=99% bgcolor=white>';
$userdbname=$_COOKIE['username'].'playlist';
$result = mysql_query("SELECT * FROM $userdbname order by id desc limit 0, 16");

// keeps getting the next row until there are no more to get
$cols = 4; # Number of columns to display 
$colCtr = 0; 
while($row = mysql_fetch_array( $result )) {
$sname = substr($row['vname'], 0, 50);
if($row['image']==''){
$row['image']='nophoto.png';
}
echo '<td width=200 height=200 align=left><center><a href="playlisteditor.php?='. $row['id']. '"><img src="thumbs/'. $row['image']. '" width=200 height=120 alt="'. $sname. '" title="'. $sname. '"><font size=4><br><b>'. $row['title']. '</a></td>'; 
if($colCtr %$cols == 3){ 
echo '</table><table width=100% border=0 cellpadding=2 cellspacing=0><tr><td bgcolor=#83D6FC width=99% height=1></td></table><table bgcolor=white><tr>'; 
}else{}
if($row['id']=15){ 
end($row);
}
$colCtr++; 
}
?>
</table></td></table>
<?php include("headerbottom.php"); ?>
</body></html>
