<?php

if (!empty($_GET['del']) && is_numeric($_GET['del']))
{
	$del = abs(intval($_GET['del']));

	if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `audioplaylist` WHERE `user_id` = '".$user_id."' LIMIT 1"),0) == true)
	{
		$arr_pl = mysql_fetch_array(mysql_query("SELECT * FROM `audioplaylist` WHERE `user_id` = '".$user_id."' LIMIT 1"));
		if (in_array($del, explode("||", substr($arr_pl['tracks'], 1, -1))))
		{
			mysql_query("UPDATE `audioplaylist` SET `tracks` = '".str_replace("|".$del."|", "", $arr_pl['tracks'])."', count=count-1 WHERE `user_id` = '".$user_id."' LIMIT 1");
			mysql_query("UPDATE `users` SET count_audio=count_audio-1 WHERE `id` = '".$user_id."'");
			
			$arr_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$user_id."'"));
		}
	}
}

?>