<?php include_once("class/class.MySQL.php");
$db	=new MySQL();

$dat1=date("Y-m-d",strtotime($_POST['frm']));
$dat2=date("Y-m-d",strtotime($_POST['tos']));
$num_count = mysql_num_rows(mysql_query("SELECT * FROM project_plan_master where date_from='$dat1' and date_to='$dat2'"));
if($num_count==0)
{
mysql_query("DELETE FROM project_plan_master");

	$data['date_from'] = date("Y-m-d",strtotime($_POST['frm']));
	$data['date_to'] = date("Y-m-d",strtotime($_POST['tos']));
	$data['weeks'] = 1;

	$db->Insert($data,'project_plan_master');
	$pid = $db->LastInsertID();
}
else
{
$num_val = mysql_fetch_array(mysql_query("SELECT * FROM project_plan_master "));
$pid = $num_val['id'];
}
?>