<? include_once("../includes/main.inc.php");

$page_id = $_REQUEST['page_id'];
$country_id = '1';

if(is_post_back()) {

if($page_id!='') {		 		

		$sql = "update `tbl_county` set county_name='".addslashes($county_name)."', county_short_name='".addslashes($county_short_name)."',  county_status='$county_status', state_id='".addslashes($state_id)."', country_id='".addslashes($country_id)."', title='".addslashes($title)."', description='".addslashes($description)."', keyword='".addslashes($keyword)."', county_descriptions='".addslashes($county_descriptions)."' where county_id = $page_id ";
		db_query($sql);

		set_session_msg("state records updated successfully.");	
	    header("Location: taluk.php?start=$start");

	exit;

	} else{	

		$sql = "insert into `tbl_county` set county_name='".addslashes($county_name)."', county_status='$county_status', county_short_name='".addslashes($county_short_name)."', state_id='".addslashes($state_id)."', country_id='".addslashes($country_id)."',title='".addslashes($title)."',description='".addslashes($description)."', keyword='".addslashes($keyword)."', county_descriptions='".addslashes($county_descriptions)."'";

		db_query($sql);
		//echo '<pre>'; print_r($sql);
		set_session_msg("New state records added successfully.");
    	header("Location: taluk.php?start=$start");
    	exit;

	}
}

$page_id = $_REQUEST['page_id'];

if($page_id!='') {

	 $sql = "select `tbl_county`.* from `tbl_county` left join `tbl_state` on `tbl_county`.state_id=`tbl_state`.state_id left join `tbl_country` on `tbl_county`.country_id=`tbl_country`.country_id where county_id = '$page_id'";

	$result = db_query($sql);

	if ($line_raw = mysql_fetch_array($result)) {

		@extract($line_raw);

	}

}

?>

<link href="styles.css" rel="stylesheet" type="text/css">

<? include("top.inc.php");?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td id="pageHead"><div id="txtPageHead">

       Add/Edit - County Name</div></td>

  </tr>

</table>

<script type="text/javascript" src="fckeditor/fckeditor.js"></script>

<table width="80%" align="left">

		  	<tr><td>

		  	<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return validate(this);">

		  	<input type="hidden" name="hfstateId" id="hfstateId" value="<?php echo $state_id; ?>">

        <table width="80%" align="center" border=0 cellpadding="0"  cellspacing="0" class="text">

    	<tr>

		<td  colspan="2"height="30"  align="right"><a href="taluk.php?start=<?=$start?>" class="redcolor"><strong>Back To County List</strong></a></td>

		</tr>    

        <tr><td height="15"><div align="center"><span class="msg"><?=display_sess_msg();?></span></div><br /></td></tr>  


<tr>
<td class="lables"><b>State Name</b></td>
<td class="feildstxt">
<select id="state_id" name="state_id">
<?php
$sqls=mysql_query("select * from tbl_state where state_status=1 order by state_name ASC");
while($ress=mysql_fetch_array($sqls))
{
if($ress['state_id']==$state_id)
{
echo "<option value='".$ress['state_id']."' selected>".$ress['state_name']."</option>";
}
else
{
echo "<option value='".$ress['state_id']."'>".$ress['state_name']."</option>";
}
}
?>
</select>
</td>
</tr>

<tr><td>&nbsp;</td></tr> 

<tr>
<td class="lables"><b>County Name</b></td>
<td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($county_name)?>" name="county_name" id="county_name"  /></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>County Short Name</b></td>
<td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($county_short_name)?>" name="county_short_name" id="county_short_name"  /></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Status</b></td>
<td class="feildstxt"><select name="county_status" id="county_status">
<option value="1" <?php if($county_status=='1'){ echo 'selected="selected"'; } ?>>Active</option>
<option value="0" <?php if($county_status=='0'){ echo 'selected="selected"'; } ?>>InActive</option>          
</select></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables" colspan="2"><hr/></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td align="left" class="lables">&nbsp;</td>
<td align="left" class="feildstxt"><input class="button" type="submit" name="submit" value="Save"></td>
</tr>

        <tr><td height="25">&nbsp;</td></tr>

   </table>

    </form>

    </td></tr></table>  

    <script>

    function getState()

	{

		$("#state_id").html('<option value="">&nbsp;&nbsp;&nbsp;Loading...&nbsp;&nbsp;&nbsp;</option>');

		$.post('get_state.php',{country_id:$("#country_id").val(),edit_state_id:$("#hfstateId").val()},function(data,status){

			if(status='success')

			{	

				$("#state_id").html(data);

			}

			else{

				alert("Something Going Error");	

			}

		});

	}
	// getState();
</script>  
<? include("bottom.inc.php");?>