<?php
include("../include/config.php");
//require_once "../include/Database_functions.php";
//$sqlObj=new sqlclass();

if(isset($_GET['editid']) && $_GET['editid']!='')
{

$editid=$_GET['editid'];
$edit_drop=mysql_query("select * from cf_account_groups where status=1 and id='$editid'");
if($edit_drop && mysql_num_rows($edit_drop)>0){

while($edit_res=mysql_fetch_array($edit_drop))
{
 $group_name=$edit_res['category'];
$parent_name=$edit_res['mainid'];
}
}
?>
<form name="frm" method="post">
<table width="57%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:25px;">
<tr><input type="hidden" name="hid_id" id="hid_id" value="<?=$editid?>" />
<td width="300px;">Group Name</td><td width="100px;"><input type="text" name="addgroup_name" id="addgroup_name" value="<?=$group_name?>" class="input1"></td>
</tr><tr>
<td width="400px;">Parent Group</td><td width="100px;"> <select name="addparent_name" id="addparent_name" class="input1" >
	 <option value="">Select one</option>
	 <?php
	 	$cf_drop="select * from cf_account_groups where status=1 ";
$cf_array=mysql_query($cf_drop);
if($cf_array && mysql_num_rows($cf_array)>0){

while($cf_res=mysql_fetch_array($cf_array))
{

?>
<option <?php if($cf_res['id']==$parent_name){?> selected="selected" <?php } ?> value="<?=$cf_res['id']?>"><?=$cf_res['category']?></option>

<?php
}
	} 
	 ?>
	 </select></td>
</tr>
<tr><td><input type="submit" name="editgroup" value="Update" class="input1"></td>
</form>
</tr>
  </table>
<?php
}
else
{?>
<form name="frm" method="post">
<table width="57%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:25px;">
<tr>
<td width="300px;">Group Name</td><td width="100px;"><input type="text" name="addgroup_name" id="addgroup_name" value="" class="input1"></td>
</tr><tr>
<td width="400px;">Parent Group</td><td width="100px;"> <select name="addparent_name" id="addparent_name" class="input1" >
	 <option value="">Select one</option>
	 <?php
	 	$cf_drop="select * from cf_account_groups where status=1 ";
$cf_array=mysql_query($cf_drop);
if($cf_array && mysql_num_rows($cf_array)>0){

while($cf_res=mysql_fetch_array($cf_array))
{

?>
<option value="<?=$cf_res['id']?>"><?=$cf_res['category']?></option>

<?php
}
	} 
	 ?>
	 </select></td>
</tr>
<tr><td><input type="submit" name="addgroup" value="Submit" class="input1"></td>
</form>
</tr>
  </table>
  <?php
}  ?>