<?php
function create_affiliatecategory_dropdown($mastertableid)
{
 global $availability;
	$sqlco = "SELECT id,name FROM single_field_table  where mastertableid='$mastertableid'";
	$result_shipping_charge = mysql_query($sqlco);
	$row_shipping_charge  = mysql_num_rows($result_shipping_charge );
	if($row_shipping_charge > 0)
	{  
		$field = "<select name='affiliatecategory[]' id='affiliatecategory[]' multiple";
		$field .= '>';
		while($data_shipping_charge = mysql_fetch_object($result_shipping_charge))
		{			
			   $values=$data_shipping_charge->id;
			   $field .= '<option value="' . $values. '"';
			   if(isset($_POST['affiliatecategory']))
			   {
			     $availability=$_POST['affiliatecategory'];
			   }	
			   
			   /*if($values==$country) 
			   {
				  $field .= ' selected';
			   }	*/
			   if(is_array($availability))
			   {
			 
			     if(in_array($data_shipping_charge->id,$availability)){$field .= ' selected';}
			   }	 
			   $field .= '>' .$data_shipping_charge->name . '</option>';
		 }
		 $field .= '</select>';
		 echo  $field;
	}
}

function getfileExtension($file_name)
{
$fileextension_arr = explode(".",$file_name);
$getCounts = count($fileextension_arr)-1;
$ext = $fileextension_arr[$getCounts];
return $ext;
}
?>