<? 
ob_start();
session_start();
require_once("../dbconnect.php");

  $action = isset($_GET['action']) ? $_GET['action'] : '';

switch ($action) {
	
    case 'feature' :
        featureproduct();
        break;
		
	    case 'delete' :
        deleteproduct();
        break;
		
		case 'update' :
        updateproduct();
        break;
		
		
	    default :
        // if action is not defined or unknown
        // move to main category page
        header('Location: viewfeatured.php');
		
		}
		
		
//*fetured product*/
function featureproduct()
{

$fsdate=$_POST['fsdate'];
$fedate=$_POST['fedate'];

$sql1="Select * from products WHERE pid IN(".implode(",",$_POST['match']).")";
 $count=count($_POST['match']);
$res=mysql_query($sql1);
   for ($i=0; $i<$count; $i++)
                         {
							 
$str12="update products set fsdate='".$fsdate."',fedate='".$fedate."',featured=1  where pid=".$_POST['match'][$i]; 
                           $res12=mysql_query($str12);  
						   
	header('Location: viewfeatured.php');   					   
						   
						 }



}
//*delete product*/
function deleteproduct()
{
	
	$userid=$_POST['userid'];
	
$str12="update products set fsdate=' ',fedate='',featured=0  where pid=".$userid; 
  $res12=mysql_query($str12);  
						   
header('Location: viewfeatured.php?sdel=sdel');

}
//**update product**//
function updateproduct()
{
	
$fsdate=$_POST['fsdate'];
$fedate=$_POST['fedate'];

$userid=$_POST['userid'];

echo $str12="update products set fsdate='".$fsdate."',fedate='".$fedate."',featured=1  where pid=".$userid;  
                           $res12=mysql_query($str12);  
						   
	header('Location: viewfeatured.php');   		
	
}
	


?>