Location: PHPKode > projects > ComicFlow > comicreport.php
<?php

// Include needed files
include("./class.TemplatePower.inc.php");
include("./config/config.php");

// Create a new template object
if($_POST['tool_option'] == 'comic')
	{

		if($_POST['tool_comic_cat'] == 'series')
			{
				$tpl = new TemplatePower("themes/$themes/tpl/report_comic.tpl");
			} else {
				$tpl = new TemplatePower("themes/$themes/tpl/report_category.tpl");
			}
		
	} elseif($_POST['tool_option'] == 'artist') {
		
		if($_POST['tool_artist_name'] == 'Series')
			{
				$tpl = new TemplatePower("themes/$themes/tpl/report_series.tpl");
			} else {
				$tpl = new TemplatePower("themes/$themes/tpl/report_artist.tpl");
			}	
		
	} elseif($_POST['tool_option'] == 'favs') {
		
		$tpl = new TemplatePower("themes/$themes/tpl/report_favs.tpl");
		
	} elseif($_POST['tool_option'] == 'location') {
		
		$tpl = new TemplatePower("themes/$themes/tpl/report_location.tpl");
		
	}

// Prepare the template
$tpl->prepare();

// GET THE MENU AND LANGUAGE FILES
include("./lang/$language/report.lang.php");

$tpl->assignGlobal("theme", $themes);
$tpl->assignGlobal("pmcurl", $siteurl);
$tpl->assignGlobal("sitetitle", $sitetitle);
$tpl->assignGlobal("imgfolder", "themes/$themes/img");
$tpl->assign("version", $version);

// MySQL Connection
mysql_connect($sql['host'],$sql['user'],$sql['pass']) or die("Unable to connect to SQL server");
mysql_select_db($sql['data']) or die("Unable to find DB");

// GET TODAYS DATE FOR THE REPORT
$dat = date("Y-m-d G-i-s");
$query = "SELECT date_format('$dat','%W, %M %d, %Y')";
$getdate = mysql_db_query($sql['data'], $query) or die("Select date user format Failed!");
$row = mysql_fetch_array($getdate);
$newdate = $row[0];

$tpl->assign("report_date", $newdate);

// CHECK IF THIS IS A COMIC REPORT
if($_POST['tool_option'] == 'comic')
	{
		
		if($_POST['tool_comic_cat'] == 'series')
			{

				// The MySQL query with SORT option
				$comselect = "SELECT * FROM pmc_artist WHERE type = 'Series' ORDER BY name, volume";					
				
				// Run the query
				$comdata = mysql_db_query($sql['data'], $comselect) or die("Select series in comic report where cat is none!");
				
				while ($comrow = mysql_fetch_array($comdata))
					{
				   	
				   		$getname = $comrow['uid'];
				   		$thename = $comrow['name'];
					   	$volume = $comrow['volume'];
					   	$publisher = $comrow['publisher'];
					   	$type = $comrow['comtype'];
					   	$genre = $comrow['genre'];
					   	$year = $comrow['year'];
					   	
					   	// Get Type
						$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
						$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						$row = mysql_fetch_array($dat);
						$type_uid = $row['name'];
						      	
						// Get Genre
						$select = "SELECT * FROM pmc_artist WHERE uid = '$genre'";
						$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						$row = mysql_fetch_array($dat);
						$genre_uid = $row['name'];
						
						// Get Publisher name
						$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
						$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						$row = mysql_fetch_array($dat);
						$pub_uid = $row['name'];
					   	
					   	$tpl->newBlock("comic_name");
					   	$tpl->assign("series_name", $thename);
					   	$tpl->assign("series_genre", $genre_uid);
					   	$tpl->assign("series_pub", $pub_uid);
					   	$tpl->assign("series_type", $type_uid);
					   	$tpl->assign("series_volume", $volume);
					   	$tpl->assign("series_year", $year);					   						   	
					   	
					   	// USER CUSTOM FIELD HEAD TEXT
					   	if($_POST['tool_comic_f1'] == 'price') {
						 	$field_head_1 = $lang_list_price;
						} elseif($_POST['tool_comic_f1'] == 'value') {
						    $field_head_1 = $lang_list_value;
						} elseif($_POST['tool_comic_f1'] == 'location') {
						    $field_head_1 = $lang_list_location;
						} elseif($_POST['tool_comic_f1'] == 'rating') {
						    $field_head_1 = $lang_list_rating;
						} 
						      		
						if($_POST['tool_comic_f2'] == 'price') {
							$field_head_2 = $lang_list_price;
						} elseif($_POST['tool_comic_f2'] == 'value') {
						    $field_head_2 = $lang_list_value;
						} elseif($_POST['tool_comic_f2'] == 'location') {
						    $field_head_2 = $lang_list_location;
						} elseif($_POST['tool_comic_f2'] == 'rating') {
						    $field_head_2 = $lang_list_rating;
						} 
						      						
						// GET ALL COMICS BY SERIES
						$listsort = $_POST['tool_comic_sort'];
						
						// SORT RESULT BY USERS OPTION
						if($_POST['tool_comic_list'] == 'issue')
							{
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
							} elseif($_POST['tool_comic_list'] == 'location') {
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY location $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'rating') {
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY rating $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'price') {
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY price $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'value') {
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY value $listsort, issue, issueltr";
							} else {
								$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
							}
						
						$data = mysql_db_query($sql['data'], $select) or die("Select dd Failed!");										
						
						// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
						$anycomic = mysql_num_rows($data);
						if($anycomic == '')
							{
								$tpl->assign("pmc_anycomic", "<tr><td colspan=\"6\" class=\"cell\">There are no comics in your database connected to this publisher.</td></tr>");	
							} else {
								$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_number</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_story</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_variation</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_condition</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
							}
				
						while($row = mysql_fetch_array($data))
							{
					   
					      		// Get all the fields
						      	$issue = $row['issue'];
						      	$issueltr = $row['issueltr'];
						      	$title = $row['title'];
						      	$story = $row['story'];
						      	$cost = $row['price'];
						      	$value = $row['value'];
						      	$currency = $row['currency'];
						      	$location = $row['location'];
						      	$rating = $row['rating'];
						      	$variation = $row['variation'];
						      	$condition = $row['condition'];								      			 
				      
				      			$tpl->newBlock("comic_report");   					      			
						      	
						      	// Get currency
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$cost_uid = $row['name'];						      							      	
						      	
						      	// Get Variation
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$variation_uid = $row['name'];
						      	
						      	// Get Condotion
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$condition_uid = $row['name'];
						      	
						      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
						      	$tpl->assign("field_story", "<td nowrap=\"nowrap\" class=\"cell\">$story</td>");
						      	$tpl->assign("field_condition", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      	$tpl->assign("field_variation", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      	
						      	// THE USER CUSTOM FIELD
						      	if($_POST['tool_comic_f1'] == 'price') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_comic_f1'] == 'value') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_comic_f1'] == 'location') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
						      		} elseif($_POST['tool_comic_f1'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		} 
						      	
						      	// THE USER CUSTOM FIELD	
						      	if($_POST['tool_comic_f2'] == 'price') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_comic_f2'] == 'value') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_comic_f2'] == 'location') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
						      		} elseif($_POST['tool_comic_f2'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}

						      		} 
						      	
							}
					}
					
			} elseif($_POST['tool_comic_cat'] == 'publisher') {
				
				// Get ALL PUBLISHERS
				$getpub = "SELECT * FROM pmc_artist WHERE type = 'Publisher' ORDER BY name";

				$compub = mysql_db_query($sql['data'], $getpub) or die("PUB DIED!");

				while ($pubrow = mysql_fetch_array($compub))

				{
				
					$publishername = $pubrow['uid'];
					
					// GET PUBLISHER NAME
					$select = "SELECT * FROM pmc_artist WHERE uid = '$publishername'";
	      			$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
	      			$row = mysql_fetch_array($dat);
	      			$pub_uid = $row['name'];
	
	 				$tpl->newBlock("publisher_list");
					$tpl->assign("pmc_category", "<tr><td colspan=\"6\" class=\"cell_category\">$pub_uid</td></tr><tr><td class=\"emty\"><div class=\"emty\"></div></td></tr>"); 
		
					// The MySQL query with SORT option
					$comselect = "SELECT * FROM pmc_artist WHERE type = 'Series' AND publisher = '$publishername' ORDER BY name, volume";					
					
					// Run the query
					$comdata = mysql_db_query($sql['data'], $comselect) or die("Select series in comic report where cat is none!");
					
					while ($comrow = mysql_fetch_array($comdata))
						{
					   	
					   		$getname = $comrow['uid'];
					   		$thename = $comrow['name'];
						   	$volume = $comrow['volume'];
						   	$publisher = $comrow['publisher'];
						   	$type = $comrow['comtype'];
						   	$genre = $comrow['genre'];
						   	$year = $comrow['year'];
						   	
						   	// Get Type
							$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$type_uid = $row['name'];
							      	
							// Get Genre
							$select = "SELECT * FROM pmc_artist WHERE uid = '$genre'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$genre_uid = $row['name'];
							
							// Get Publisher name
							$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$pub_uid = $row['name'];
						   	
						   	$tpl->newBlock("comic_name");
						   	$tpl->assign("series_name", $thename);
						   	$tpl->assign("series_genre", $genre_uid);
						   	$tpl->assign("series_pub", $pub_uid);
						   	$tpl->assign("series_type", $type_uid);
						   	$tpl->assign("series_volume", $volume);
						   	$tpl->assign("series_year", $year);					   						   	
						   	
						   	// USER CUSTOM FIELD HEAD TEXT
						   	if($_POST['tool_comic_f1'] == 'price') {
							 	$field_head_1 = $lang_list_price;
							} elseif($_POST['tool_comic_f1'] == 'value') {
							    $field_head_1 = $lang_list_value;
							} elseif($_POST['tool_comic_f1'] == 'location') {
							    $field_head_1 = $lang_list_location;
							} elseif($_POST['tool_comic_f1'] == 'rating') {
							    $field_head_1 = $lang_list_rating;
							} 
							      		
							if($_POST['tool_comic_f2'] == 'price') {
								$field_head_2 = $lang_list_price;
							} elseif($_POST['tool_comic_f2'] == 'value') {
							    $field_head_2 = $lang_list_value;
							} elseif($_POST['tool_comic_f2'] == 'location') {
							    $field_head_2 = $lang_list_location;
							} elseif($_POST['tool_comic_f2'] == 'rating') {
							    $field_head_2 = $lang_list_rating;
							} 
							      						
							// GET ALL COMICS BY SERIES
							$listsort = $_POST['tool_comic_sort'];
							
							// SORT RESULT BY USERS OPTION
							if($_POST['tool_comic_list'] == 'issue')
								{
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
								} elseif($_POST['tool_comic_list'] == 'location') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY location $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'rating') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY rating $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'price') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY price $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'value') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY value $listsort, issue, issueltr";
								} else {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
								}
							
							$data = mysql_db_query($sql['data'], $select) or die("Select dd Failed!");										
							
							// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
							$anycomic = mysql_num_rows($data);
							if($anycomic == '')
								{
									$tpl->assign("pmc_anycomic", "<tr><td colspan=\"6\" class=\"cell\">There are no comics in your database connected to this publisher.</td></tr>");	
								} else {
									$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_number</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_story</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_variation</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_condition</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
								}
					
							while($row = mysql_fetch_array($data))
								{
						   
						      		// Get all the fields
							      	$issue = $row['issue'];
							      	$issueltr = $row['issueltr'];
							      	$title = $row['title'];
							      	$story = $row['story'];
							      	$cost = $row['price'];
							      	$value = $row['value'];
							      	$currency = $row['currency'];
							      	$location = $row['location'];
							      	$rating = $row['rating'];
							      	$variation = $row['variation'];
							      	$condition = $row['condition'];								      			 
					      
					      			$tpl->newBlock("comic_report");   					      			
							      	
							      	// Get currency
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$cost_uid = $row['name'];						      							      	
							      	
							      	// Get Variation
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$variation_uid = $row['name'];
							      	
							      	// Get Condotion
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$condition_uid = $row['name'];
							      	
							      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
							      	$tpl->assign("field_story", "<td nowrap=\"nowrap\" class=\"cell\">$story</td>");
							      	$tpl->assign("field_condition", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
							      	$tpl->assign("field_variation", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
							      	
							      	// THE USER CUSTOM FIELD
							      	if($_POST['tool_comic_f1'] == 'price') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'value') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'location') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'rating') {
							      			
							      			// MAKE THE RATING STARS
							      			if($rating == '0')
							      				{
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
							      				} elseif($rating == '1') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
							      				} elseif($rating == '2') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
							      				} elseif($rating == '3') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
							      				} elseif($rating == '4') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
							      				} elseif($rating == '5') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
							      				}
							      				
							      		} 
							      	
							      	// THE USER CUSTOM FIELD	
							      	if($_POST['tool_comic_f2'] == 'price') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'value') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'location') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'rating') {
							      			
							      			// MAKE THE RATING STARS
							      			if($rating == '0')
							      				{
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
							      				} elseif($rating == '1') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
							      				} elseif($rating == '2') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
							      				} elseif($rating == '3') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
							      				} elseif($rating == '4') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
							      				} elseif($rating == '5') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
							      				}
	
							      		} 
							      	
								}
						}
					
				}
				
			} elseif($_POST['tool_comic_cat'] == 'genre') {
				
				// Get ALL PUBLISHERS
				$getpub = "SELECT * FROM pmc_artist WHERE type = 'Genre' ORDER BY name";

				$compub = mysql_db_query($sql['data'], $getpub) or die("PUB DIED!");

				while ($pubrow = mysql_fetch_array($compub))

				{
				
					$publishername = $pubrow['uid'];
					
					// GET PUBLISHER NAME
					$select = "SELECT * FROM pmc_artist WHERE uid = '$publishername'";
	      			$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
	      			$row = mysql_fetch_array($dat);
	      			$pub_uid = $row['name'];
	
	 				$tpl->newBlock("publisher_list");
					$tpl->assign("pmc_category", "<tr><td colspan=\"6\" class=\"cell_category\">$pub_uid</td></tr><tr><td class=\"emty\"><div class=\"emty\"></div></td></tr>"); 
		
					// The MySQL query with SORT option
					$comselect = "SELECT * FROM pmc_artist WHERE type = 'Series' AND genre = '$publishername' ORDER BY name, volume";					
					
					// Run the query
					$comdata = mysql_db_query($sql['data'], $comselect) or die("Select series in comic report where cat is none!");
					
					while ($comrow = mysql_fetch_array($comdata))
						{
					   	
					   		$getname = $comrow['uid'];
					   		$thename = $comrow['name'];
						   	$volume = $comrow['volume'];
						   	$publisher = $comrow['publisher'];
						   	$type = $comrow['comtype'];
						   	$genre = $comrow['genre'];
						   	$year = $comrow['year'];
						   	
						   	// Get Type
							$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$type_uid = $row['name'];
							      	
							// Get Genre
							$select = "SELECT * FROM pmc_artist WHERE uid = '$genre'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$genre_uid = $row['name'];
							
							// Get Publisher name
							$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
							$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							$row = mysql_fetch_array($dat);
							$pub_uid = $row['name'];
						   	
						   	$tpl->newBlock("comic_name");
						   	$tpl->assign("series_name", $thename);
						   	$tpl->assign("series_genre", $genre_uid);
						   	$tpl->assign("series_pub", $pub_uid);
						   	$tpl->assign("series_type", $type_uid);
						   	$tpl->assign("series_volume", $volume);
						   	$tpl->assign("series_year", $year);					   						   	
						   	
						   	// USER CUSTOM FIELD HEAD TEXT
						   	if($_POST['tool_comic_f1'] == 'price') {
							 	$field_head_1 = $lang_list_price;
							} elseif($_POST['tool_comic_f1'] == 'value') {
							    $field_head_1 = $lang_list_value;
							} elseif($_POST['tool_comic_f1'] == 'location') {
							    $field_head_1 = $lang_list_location;
							} elseif($_POST['tool_comic_f1'] == 'rating') {
							    $field_head_1 = $lang_list_rating;
							} 
							      		
							if($_POST['tool_comic_f2'] == 'price') {
								$field_head_2 = $lang_list_price;
							} elseif($_POST['tool_comic_f2'] == 'value') {
							    $field_head_2 = $lang_list_value;
							} elseif($_POST['tool_comic_f2'] == 'location') {
							    $field_head_2 = $lang_list_location;
							} elseif($_POST['tool_comic_f2'] == 'rating') {
							    $field_head_2 = $lang_list_rating;
							} 
							      						
							// GET ALL COMICS BY SERIES
							$listsort = $_POST['tool_comic_sort'];
							
							// SORT RESULT BY USERS OPTION
							if($_POST['tool_comic_list'] == 'issue')
								{
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
								} elseif($_POST['tool_comic_list'] == 'location') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY location $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'rating') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY rating $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'price') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY price $listsort, issue, issueltr";
								} elseif($_POST['tool_comic_list'] == 'value') {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY value $listsort, issue, issueltr";
								} else {
									$select = "SELECT * FROM pmc_comic WHERE title = $getname ORDER BY issue $listsort, issueltr";
								}
							
							$data = mysql_db_query($sql['data'], $select) or die("Select dd Failed!");										
							
							// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
							$anycomic = mysql_num_rows($data);
							if($anycomic == '')
								{
									$tpl->assign("pmc_anycomic", "<tr><td colspan=\"6\" class=\"cell\">There are no comics in your database connected to this publisher.</td></tr>");	
								} else {
									$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_number</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_story</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_variation</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_condition</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
								}
					
							while($row = mysql_fetch_array($data))
								{
						   
						      		// Get all the fields
							      	$issue = $row['issue'];
							      	$issueltr = $row['issueltr'];
							      	$title = $row['title'];
							      	$story = $row['story'];
							      	$cost = $row['price'];
							      	$value = $row['value'];
							      	$currency = $row['currency'];
							      	$location = $row['location'];
							      	$rating = $row['rating'];
							      	$variation = $row['variation'];
							      	$condition = $row['condition'];								      			 
					      
					      			$tpl->newBlock("comic_report");   					      			
							      	
							      	// Get currency
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$cost_uid = $row['name'];						      							      	
							      	
							      	// Get Variation
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$variation_uid = $row['name'];
							      	
							      	// Get Condotion
							      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
							      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
							      	$row = mysql_fetch_array($dat);
							      	$condition_uid = $row['name'];
							      	
							      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
							      	$tpl->assign("field_story", "<td nowrap=\"nowrap\" class=\"cell\">$story</td>");
							      	$tpl->assign("field_condition", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
							      	$tpl->assign("field_variation", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
							      	
							      	// THE USER CUSTOM FIELD
							      	if($_POST['tool_comic_f1'] == 'price') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'value') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'location') {
							      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
							      		} elseif($_POST['tool_comic_f1'] == 'rating') {
							      			
							      			// MAKE THE RATING STARS
							      			if($rating == '0')
							      				{
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
							      				} elseif($rating == '1') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
							      				} elseif($rating == '2') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
							      				} elseif($rating == '3') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
							      				} elseif($rating == '4') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
							      				} elseif($rating == '5') {
							      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
							      				}
							      				
							      		} 
							      	
							      	// THE USER CUSTOM FIELD	
							      	if($_POST['tool_comic_f2'] == 'price') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'value') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'location') {
							      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$location</td>");
							      		} elseif($_POST['tool_comic_f2'] == 'rating') {
							      			
							      			// MAKE THE RATING STARS
							      			if($rating == '0')
							      				{
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
							      				} elseif($rating == '1') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
							      				} elseif($rating == '2') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
							      				} elseif($rating == '3') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
							      				} elseif($rating == '4') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
							      				} elseif($rating == '5') {
							      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
							      				}
	
							      		} 
							      	
								}
						}
					
				}
				
			}
		
	} elseif($_POST['tool_option'] == 'artist') {
		
		if($_POST['tool_artist_name'] == 'Series')
			
			{
				
				$tpl->assign("listname", $lang_artist_series);
				
				// The MySQL query with SORT option
				$comselect = "SELECT  * FROM pmc_artist WHERE type = '".$_POST['tool_artist_name']."' ORDER BY name";									
				
				// Run the query
				$comdata = mysql_db_query($sql['data'], $comselect) or die("Select location failed!");
				
				$anycomic = mysql_num_rows($comdata);
				if($anycomic == '')
					{
						$tpl->assign("pmc_numcomic", "No Comics");	
					} else {
						$tpl->assign("pmc_numcomic", $anycomic);	
					}
				
				while ($comrow = mysql_fetch_array($comdata))
					{
						
						$artistname = $comrow['name'];
						$ser_pub = $comrow['publisher'];
						$ser_type = $comrow['comtype'];
						$ser_vol = $comrow['volume'];
						$ser_year = $comrow['year'];
						
						// Get publisher
						$select = "SELECT * FROM pmc_artist WHERE uid = '$ser_pub'";
				    	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
				      	$row = mysql_fetch_array($dat);
				      	$publisher_uid = $row['name'];
				      	
				      	// Get type
						$select = "SELECT * FROM pmc_artist WHERE uid = '$ser_type'";
				    	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
				      	$row = mysql_fetch_array($dat);
				      	$type_uid = $row['name'];						      				
						
						$tpl->newBlock("artist_report");
						$tpl->assign("sername", $artistname);
						$tpl->assign("serpub", $publisher_uid);
						$tpl->assign("sertype", $type_uid);
						$tpl->assign("seryear", $ser_year);
						$tpl->assign("servolume", $ser_vol);						
					}
				
			} else {
				
				if($_POST['tool_artist_name'] == 'all')
					{
						$tpl->assign("listname", $lang_artist_all);
					} elseif($_POST['tool_artist_name'] == 'Publisher') {
						$tpl->assign("listname", $lang_artist_pub);
					} elseif($_POST['tool_artist_name'] == 'Genre') {
						$tpl->assign("listname", $lang_artist_genre);
					} elseif($_POST['tool_artist_name'] == 'Writer') {
						$tpl->assign("listname", $lang_artist_writer);
					} elseif($_POST['tool_artist_name'] == 'Penciler') {
						$tpl->assign("listname", $lang_artist_penciler);
					} elseif($_POST['tool_artist_name'] == 'Inker') {
						$tpl->assign("listname", $lang_artist_inker);
					} elseif($_POST['tool_artist_name'] == 'Colorist') {
						$tpl->assign("listname", $lang_artist_colorist);
					} elseif($_POST['tool_artist_name'] == 'Letterer') {
						$tpl->assign("listname", $lang_artist_letterer);
					} elseif($_POST['tool_artist_name'] == 'Coverartist') {
						$tpl->assign("listname", $lang_artist_cover);
					}
				
				// The MySQL query with SORT option
				if($_POST['tool_artist_name'] == 'all')
					{
						$comselect = "SELECT DISTINCT name FROM pmc_artist WHERE type = 'Writer' OR type = 'Penciler' OR type = 'Inker' OR type = 'Colorist' OR type = 'Letterer' OR type = 'Coverartist' ORDER BY name";
					} else {
						$comselect = "SELECT  * FROM pmc_artist WHERE type = '".$_POST['tool_artist_name']."' ORDER BY name";	
					}								
				
				// Run the query
				$comdata = mysql_db_query($sql['data'], $comselect) or die("Select location failed!");
				
				$anycomic = mysql_num_rows($comdata);
				if($anycomic == '')
					{
						$tpl->assign("pmc_numcomic", "No Comics");	
					} else {
						$tpl->assign("pmc_numcomic", $anycomic);	
					}
				
				while ($comrow = mysql_fetch_array($comdata))
					{
						$artistname = $comrow['name'];
						
						$tpl->newBlock("artist_report");
						$tpl->assign("artistname", $artistname);						
					}
				
			}
		
	} elseif($_POST['tool_option'] == 'favs') {
		
		$listsort = $_POST['tool_favs_sort'];
		
		// SORT RESULT BY USERS OPTION
						if($_POST['tool_favs_list'] == 'issue')
							{
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY issue $listsort, issueltr";
							} elseif($_POST['tool_favs_list'] == 'location') {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY location $listsort, issue, issueltr";
							} elseif($_POST['tool_favs_list'] == 'rating') {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY rating $listsort, issue, issueltr";
							} elseif($_POST['tool_favs_list'] == 'price') {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY price $listsort, issue, issueltr";
							} elseif($_POST['tool_favs_list'] == 'value') {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY value $listsort, issue, issueltr";
							} elseif($_POST['tool_favs_list'] == 'name') {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY title $listsort, issue, issueltr";
							} else {
								$select = "SELECT * FROM pmc_comic WHERE fav = 'yes' ORDER BY issue $listsort, issueltr";
							}
						
						$data = mysql_db_query($sql['data'], $select) or die("Select dddd Failed!");										
						
						// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
						$anycomic = mysql_num_rows($data);
						if($anycomic == '')
							{
								$tpl->assign("pmc_numcomic", "No Comics");	
							} else {
								$tpl->assign("pmc_numcomic", $anycomic);	
							}
						
						// USER CUSTOM FIELD HEAD TEXT
						if($_POST['tool_favs_f1'] == 'price') {
							$field_head_1 = $lang_list_price;
						} elseif($_POST['tool_favs_f1'] == 'value') {
							$field_head_1 = $lang_list_value;
						} elseif($_POST['tool_favs_f1'] == 'condition') {
							$field_head_1 = $lang_list_condition;
						} elseif($_POST['tool_favs_f1'] == 'variation') {
							$field_head_1 = $lang_list_variation;
						} elseif($_POST['tool_favs_f1'] == 'rating') {
							$field_head_1 = $lang_list_rating;
						}
						
						if($_POST['tool_favs_f2'] == 'price') {
							$field_head_2 = $lang_list_price;
						} elseif($_POST['tool_favs_f2'] == 'value') {
							$field_head_2 = $lang_list_value;
						} elseif($_POST['tool_favs_f2'] == 'condition') {
							$field_head_2 = $lang_list_condition;
						} elseif($_POST['tool_favs_f2'] == 'variation') {
							$field_head_2 = $lang_list_variation;
						} elseif($_POST['tool_favs_f2'] == 'rating') {
							$field_head_2 = $lang_list_rating;
						}  
							
						$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_title</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_volume</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_issue</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_publisher</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_type</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
				
						while($row = mysql_fetch_array($data))
							{
					   
					      		// Get all the fields
						      	$issue = $row['issue'];
						      	$issueltr = $row['issueltr'];
						      	$title = $row['title'];
						      	$story = $row['story'];
						      	$cost = $row['price'];
						      	$value = $row['value'];
						      	$currency = $row['currency'];
						      	$location = $row['location'];
						      	$rating = $row['rating'];
						      	$variation = $row['variation'];
						      	$condition = $row['condition'];
						      	
						      	// GET SERIES DETAILS
								$newselect = "SELECT * FROM pmc_artist WHERE uid = '$title'";					
				
								// Run the query
								$newdata = mysql_db_query($sql['data'], $newselect) or die("Select location failed!");				
								$newrow = mysql_fetch_array($newdata);
								
								$publisher = $newrow['publisher'];
								$type = $newrow['comtype'];
								$year = $newrow['year'];
								$volume = $newrow['volume'];
								$title_uid = $newrow['name'];					      			 
				      
				      			$tpl->newBlock("favs_report");   					      			
						      							      	
						      	// Get publisher
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$publisher_uid = $row['name'];
						      	
						      	// Get type
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$type_uid = $row['name'];
						      	
						      	// Get currency
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$cost_uid = $row['name'];						      							      	
						      	
						      	// Get Variation
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$variation_uid = $row['name'];
						      	
						      	// Get Condotion
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$condition_uid = $row['name'];
						      	
						      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
						      	$tpl->assign("field_title", "<td nowrap=\"nowrap\" class=\"cell\">$title_uid</td>");
						      	$tpl->assign("field_volume", "<td nowrap=\"nowrap\" class=\"cell\">$volume</td>");
						      	$tpl->assign("field_publisher", "<td nowrap=\"nowrap\" class=\"cell\">$publisher_uid</td>");
						      	$tpl->assign("field_type", "<td nowrap=\"nowrap\" class=\"cell\">$type_uid</td>");						      	
						      	
						      	// THE USER CUSTOM FIELD
						      	if($_POST['tool_favs_f1'] == 'price') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_favs_f1'] == 'value') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_favs_f1'] == 'condition') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_favs_f1'] == 'variation') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_favs_f1'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		} 
						      	
						      	// THE USER CUSTOM FIELD	
						      	if($_POST['tool_favs_f2'] == 'price') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_favs_f2'] == 'value') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_favs_f2'] == 'condition') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_favs_f2'] == 'variation') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_favs_f2'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		}  
						      	
							}
		
	} elseif($_POST['tool_option'] == 'location') {
		
		if($_POST['tool_loc_select'] == 'all')
		
			{

				// The MySQL query with SORT option
				$comselect = "SELECT DISTINCT location FROM pmc_comic WHERE location != '' ORDER BY location";					
				
				// Run the query
				$comdata = mysql_db_query($sql['data'], $comselect) or die("Select location failed!");
				
				while ($comrow = mysql_fetch_array($comdata))
					{
				   	
				   		$locationname = $comrow['location'];
					   						   						   	
					   	$tpl->newBlock("comic_name");
					   	$tpl->assign("location_name", $locationname);		   						   	
					   						   	      						
						// GET ALL COMICS BY SERIES
						$listsort = $_POST['tool_loc_sort'];
						
						// SORT RESULT BY USERS OPTION
						if($_POST['tool_loc_list'] == 'issue')
							{
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY issue $listsort, issueltr";
							} elseif($_POST['tool_loc_list'] == 'location') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY location $listsort, issue, issueltr";
							} elseif($_POST['tool_loc_list'] == 'rating') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY rating $listsort, issue, issueltr";
							} elseif($_POST['tool_loc_list'] == 'price') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY price $listsort, issue, issueltr";
							} elseif($_POST['tool_loc_list'] == 'value') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY value $listsort, issue, issueltr";
							} elseif($_POST['tool_loc_list'] == 'name') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY title $listsort, issue, issueltr";
							} else {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY issue $listsort, issueltr";
							}
						
						$data = mysql_db_query($sql['data'], $select) or die("Select dddd Failed!");										
						
						// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
						$anycomic = mysql_num_rows($data);
						if($anycomic == '')
							{
								$tpl->assign("pmc_numcomic", "No Comics");	
							} else {
								$tpl->assign("pmc_numcomic", $anycomic);	
							}
						
						// USER CUSTOM FIELD HEAD TEXT
						if($_POST['tool_loc_f1'] == 'price') {
							$field_head_1 = $lang_list_price;
						} elseif($_POST['tool_loc_f1'] == 'value') {
							$field_head_1 = $lang_list_value;
						} elseif($_POST['tool_loc_f1'] == 'condition') {
							$field_head_1 = $lang_list_condition;
						} elseif($_POST['tool_loc_f1'] == 'variation') {
							$field_head_1 = $lang_list_variation;
						} elseif($_POST['tool_loc_f1'] == 'rating') {
							$field_head_1 = $lang_list_rating;
						}
						
						if($_POST['tool_loc_f2'] == 'price') {
							$field_head_2 = $lang_list_price;
						} elseif($_POST['tool_loc_f2'] == 'value') {
							$field_head_2 = $lang_list_value;
						} elseif($_POST['tool_loc_f2'] == 'condition') {
							$field_head_2 = $lang_list_condition;
						} elseif($_POST['tool_loc_f2'] == 'variation') {
							$field_head_2 = $lang_list_variation;
						} elseif($_POST['tool_loc_f2'] == 'rating') {
							$field_head_2 = $lang_list_rating;
						}  
							
						$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_title</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_volume</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_issue</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_publisher</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_type</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
				
						while($row = mysql_fetch_array($data))
							{
					   
					      		// Get all the fields
						      	$issue = $row['issue'];
						      	$issueltr = $row['issueltr'];
						      	$title = $row['title'];
						      	$story = $row['story'];
						      	$cost = $row['price'];
						      	$value = $row['value'];
						      	$currency = $row['currency'];
						      	$location = $row['location'];
						      	$rating = $row['rating'];
						      	$variation = $row['variation'];
						      	$condition = $row['condition'];
						      	
						      	// GET SERIES DETAILS
								$newselect = "SELECT * FROM pmc_artist WHERE uid = '$title'";					
				
								// Run the query
								$newdata = mysql_db_query($sql['data'], $newselect) or die("Select location failed!");				
								$newrow = mysql_fetch_array($newdata);
								
								$publisher = $newrow['publisher'];
								$type = $newrow['comtype'];
								$year = $newrow['year'];
								$volume = $newrow['volume'];
								$title_uid = $newrow['name'];					      			 
				      
				      			$tpl->newBlock("comic_report");   					      			
						      							      	
						      	// Get publisher
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$publisher_uid = $row['name'];
						      	
						      	// Get type
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$type_uid = $row['name'];
						      	
						      	// Get currency
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$cost_uid = $row['name'];						      							      	
						      	
						      	// Get Variation
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$variation_uid = $row['name'];
						      	
						      	// Get Condotion
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$condition_uid = $row['name'];
						      	
						      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
						      	$tpl->assign("field_title", "<td nowrap=\"nowrap\" class=\"cell\">$title_uid</td>");
						      	$tpl->assign("field_volume", "<td nowrap=\"nowrap\" class=\"cell\">$volume</td>");
						      	$tpl->assign("field_publisher", "<td nowrap=\"nowrap\" class=\"cell\">$publisher_uid</td>");
						      	$tpl->assign("field_type", "<td nowrap=\"nowrap\" class=\"cell\">$type_uid</td>");						      	
						      	
						      	// THE USER CUSTOM FIELD
						      	if($_POST['tool_loc_f1'] == 'price') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'value') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'condition') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'variation') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		} 
						      	
						      	// THE USER CUSTOM FIELD	
						      	if($_POST['tool_loc_f2'] == 'price') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'value') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'condition') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'variation') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		}  
						      	
							}
					}
					
			} else {
				
				// The MySQL query with SORT option
				$comselect = "SELECT DISTINCT location FROM pmc_comic WHERE location = '".$_POST['tool_loc_select']."' ORDER BY location";					
				
				// Run the query
				$comdata = mysql_db_query($sql['data'], $comselect) or die("Select location failed!");
				
				while ($comrow = mysql_fetch_array($comdata))
					{
				   	
				   		$locationname = $comrow['location'];
					   						   						   	
					   	$tpl->newBlock("comic_name");
					   	$tpl->assign("location_name", $locationname);		   						   	
					   						   	      						
						// GET ALL COMICS BY SERIES
						$listsort = $_POST['tool_loc_sort'];
						
						// SORT RESULT BY USERS OPTION
						if($_POST['tool_loc_list'] == 'issue')
							{
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY issue $listsort, issueltr";
							} elseif($_POST['tool_comic_list'] == 'location') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY location $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'rating') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY rating $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'price') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY price $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'value') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY value $listsort, issue, issueltr";
							} elseif($_POST['tool_comic_list'] == 'name') {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY title $listsort, issue, issueltr";
							} else {
								$select = "SELECT * FROM pmc_comic WHERE location = '$locationname' ORDER BY issue $listsort, issueltr";
							}
						
						$data = mysql_db_query($sql['data'], $select) or die("Select dddd Failed!");										
						
						// MAKE HEADER AND CHECK IF THERE ARE ANY COMICS TO THIS ARTISTS      		
						$anycomic = mysql_num_rows($data);
						if($anycomic == '')
							{
								$tpl->assign("pmc_numcomic", "No Comics");	
							} else {
								$tpl->assign("pmc_numcomic", $anycomic);	
							}
						
						// USER CUSTOM FIELD HEAD TEXT
						if($_POST['tool_loc_f1'] == 'price') {
							$field_head_1 = $lang_list_price;
						} elseif($_POST['tool_loc_f1'] == 'value') {
							$field_head_1 = $lang_list_value;
						} elseif($_POST['tool_loc_f1'] == 'condition') {
							$field_head_1 = $lang_list_condition;
						} elseif($_POST['tool_loc_f1'] == 'variation') {
							$field_head_1 = $lang_list_variation;
						} elseif($_POST['tool_loc_f1'] == 'rating') {
							$field_head_1 = $lang_list_rating;
						}
						
						if($_POST['tool_loc_f2'] == 'price') {
							$field_head_2 = $lang_list_price;
						} elseif($_POST['tool_loc_f2'] == 'value') {
							$field_head_2 = $lang_list_value;
						} elseif($_POST['tool_loc_f2'] == 'condition') {
							$field_head_2 = $lang_list_condition;
						} elseif($_POST['tool_loc_f2'] == 'variation') {
							$field_head_2 = $lang_list_variation;
						} elseif($_POST['tool_loc_f2'] == 'rating') {
							$field_head_2 = $lang_list_rating;
						}  
							
						$tpl->assign("pmc_anycomic", "<tr><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_title</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_volume</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_issue</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_publisher</td><td nowrap=\"nowrap\" class=\"cellhead\">$lang_list_type</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_1</td><td nowrap=\"nowrap\" class=\"cellhead\">$field_head_2</td></tr>");
				
						while($row = mysql_fetch_array($data))
							{
					   
					      		// Get all the fields
						      	$issue = $row['issue'];
						      	$issueltr = $row['issueltr'];
						      	$title = $row['title'];
						      	$story = $row['story'];
						      	$cost = $row['price'];
						      	$value = $row['value'];
						      	$currency = $row['currency'];
						      	$location = $row['location'];
						      	$rating = $row['rating'];
						      	$variation = $row['variation'];
						      	$condition = $row['condition'];
						      	
						      	// GET SERIES DETAILS
								$newselect = "SELECT * FROM pmc_artist WHERE uid = '$title'";					
				
								// Run the query
								$newdata = mysql_db_query($sql['data'], $newselect) or die("Select location failed!");				
								$newrow = mysql_fetch_array($newdata);
								
								$publisher = $newrow['publisher'];
								$type = $newrow['comtype'];
								$year = $newrow['year'];
								$volume = $newrow['volume'];
								$title_uid = $newrow['name'];					      			 
				      
				      			$tpl->newBlock("comic_report");   					      			
						      							      	
						      	// Get publisher
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$publisher'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$publisher_uid = $row['name'];
						      	
						      	// Get type
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$type'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$type_uid = $row['name'];
						      	
						      	// Get currency
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$currency'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$cost_uid = $row['name'];						      							      	
						      	
						      	// Get Variation
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$variation'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$variation_uid = $row['name'];
						      	
						      	// Get Condotion
						      	$select = "SELECT * FROM pmc_artist WHERE uid = '$condition'";
						      	$dat = mysql_db_query($sql['data'], $select) or die("Select Failed!");
						      	$row = mysql_fetch_array($dat);
						      	$condition_uid = $row['name'];
						      	
						      	$tpl->assign("field_issue", "<td nowrap=\"nowrap\" class=\"cell\">Issue #$issue$issueltr</td>");
						      	$tpl->assign("field_title", "<td nowrap=\"nowrap\" class=\"cell\">$title_uid</td>");
						      	$tpl->assign("field_volume", "<td nowrap=\"nowrap\" class=\"cell\">$volume</td>");
						      	$tpl->assign("field_publisher", "<td nowrap=\"nowrap\" class=\"cell\">$publisher_uid</td>");
						      	$tpl->assign("field_type", "<td nowrap=\"nowrap\" class=\"cell\">$type_uid</td>");						      	
						      	
						      	// THE USER CUSTOM FIELD
						      	if($_POST['tool_loc_f1'] == 'price') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'value') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'condition') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'variation') {
						      			$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_loc_f1'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user1", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		} 
						      	
						      	// THE USER CUSTOM FIELD	
						      	if($_POST['tool_loc_f2'] == 'price') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $cost</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'value') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$cost_uid $value</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'condition') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$condition_uid</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'variation') {
						      			$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\">$variation_uid</td>");
						      		} elseif($_POST['tool_loc_f2'] == 'rating') {
						      			
						      			// MAKE THE RATING STARS
						      			if($rating == '0')
						      				{
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_0.jpg\"></td>");
						      				} elseif($rating == '1') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_1.jpg\"></td>");
						      				} elseif($rating == '2') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_2.jpg\"></td>");
						      				} elseif($rating == '3') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_3.jpg\"></td>");
						      				} elseif($rating == '4') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_4.jpg\"></td>");
						      				} elseif($rating == '5') {
						      					$tpl->assign("field_user2", "<td nowrap=\"nowrap\" class=\"cell\"><img src=\"themes/$themes/img/rate_5.jpg\"></td>");
						      				}
						      				
						      		}  
						      	
							}
					}
				
			}
		
	}
	

// Print the result
$tpl->printToScreen();

?>
Return current item: ComicFlow