<?php
	session_start();
	if (!isset($_SESSION['view_id']))
	{
		header('Location: index.php');
		exit;
	}

	$view_id = $_SESSION['view_id'];
	
	$manufacturers_name = $_GET['manufacturers_name'];
	$image_folder = $_GET['image_folder'];

	include "../connect/db_connection_2.php";
	
	// Now go ahead and delete page record from table.
	$query = "DELETE FROM zen_manufacturers WHERE manufacturers_name = '$manufacturers_name'";
	$result = mysql_query($query, $zen_link);
	
	// And delete actual folder.
	// For each category, rename the artist image folder if it exists.
	$query = "SELECT * FROM zen_categories_description";
	$result = mysql_query($query, $zen_link);
	$num_results = mysql_num_rows($result);
	for ($i = 0; $i < $num_results; $i++)
	{
		$row = mysql_fetch_array($result);
		$categories_name = $row["categories_name"];
		$cat_folder = str_replace(" ", "_", $categories_name);
		$cat_folder = strtolower($cat_folder);
		$document_root = $_SERVER['DOCUMENT_ROOT'];
		$folder_name = $document_root . "/inventory_images/$cat_folder/$image_folder";
		if (file_exists($folder_name))
		{
			// Delete folder.
			rmdir($folder_name);
		}
	}
	
	header("Location: artist.php");
	
?>
