Preview: gchildsubcat-addf.php
Size: 9.18 KB
/home/godevadmin/public_html/admin/gchildsubcat-addf.php
<?php
include("../include/config.php");
include("../include/functions.php");
validate_admin();
$cat_id=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['cat_id']);
$subcat_id=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['subcat_id']);
$chsubcat_id=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['chsubcat_id']);
if($_REQUEST['submitForm']=='yes'){
if($_REQUEST['id']==''){
if(count($_REQUEST['gchildsubcat'])>0){
foreach($_REQUEST['gchildsubcat'] as $key=>$val){
if($val!=''){
$gchildsubcat=mysqli_real_escape_string($GLOBALS['conn'],$val);
$subArr=$obj->query("select * from $tbl_gchildsubcat where cat_id='".$_REQUEST['cat_id']."' and subcat_id='$subcat_id' and chsubcat_id='$chsubcat_id' and gchildsubcat='$gchildsubcat' ");
if($obj->numRows($subArr)==0){
// echo "insert into $tbl_gchildsubcat set cat_id='$cat_id',gchildsubcat='$val',status=1";
$obj->query("insert into $tbl_gchildsubcat set cat_id='".$_REQUEST['cat_id']."',subcat_id='$subcat_id',chsubcat_id='$chsubcat_id',gchildsubcat='".ucfirst($gchildsubcat)."',status=1");
$csubcat_id=mysqli_insert_id($GLOBALS['conn']);
generateSlug($gchildsubcat,$tbl_gchildsubcat,$csubcat_id);
}
}
}
$_SESSION['sess_msg']='Grand Child subcategory added sucessfully';
}
header("location:gchildsubcat-list.php");
exit();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITE_TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
function validate(obj)
{
if(obj.cat_id.value==''){
alert("Please select category");
obj.cat_id.focus();
return false;
}
if(obj.subcat_id.value==''){
alert("Please select subcategory");
obj.subcat_id.focus();
return false;
}
if(obj.chsubcat_id.value==''){
alert("Please select child subcategory");
obj.chsubcat_id.focus();
return false;
}
var fnameInput = document.getElementsByName('gchildsubcat[]');
for (i=0; i<fnameInput.length; i++)
{
if (fnameInput[i].value == "")
{
alert('Complete all gchildsubcat fields');
return false;
}
}
}
</script>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<?php include("header.php") ?>
<script type="text/javascript">
$(document).ready(function(){
var counter = 1;
$("#add").click(function(){
var tblid="addedfield_"+counter;
$("#resultField").append('<table width="100%" border="0" cellspacing="0" cellpadding="0" id="'+tblid+'" ><tr><td align="right" class="paddBot11 paddRt14" width="23%"><strong>Child Subcategory :</strong></td><td align="left" class="paddBot11" width="77%"><input name="gchildsubcat[]" type="text" size="36" value="" /></td></tr></table>');
counter++;
})
$("#remove").click(function(){
counter=counter-1;
var tblid="#addedfield_"+counter;
$(tblid).remove();
})
})
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#cat_id").change(function(){
var cat_id=$(this).val();
$.ajax({
url:"getSubcategory.php",
data:{cat_id:cat_id},
beforeSend:function(){
$("#chsubcat_id").html("");
$("#subcat_id").html('<option value="">Select Subcategory</option>');
},
success:function(data){
$("#subcat_id").append(data);
$("#chsubcat_id").html("<option value=''>Select Child Subcategory</option>");
}
})
})
$("#subcat_id").change(function(){
var subcat_id=$(this).val();
$.ajax({
url:"getChildSubcat.php",
data:{subcat_id:subcat_id},
beforeSend:function(){
$("#chsubcat_id").html("<option value=''>Select Child Subcategory</option>");
},
success:function(data){
//alert(data);
$("#chsubcat_id").append(data);
}
})
})
})
</script>
<tr>
<td align="right" class="paddRtLt70" valign="top">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="middle" class="headingbg bodr text14">
<em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>Admin: Add Child Subcategory
<span style="float:right; padding-right:10px;">
<input type="button" name="add" value="View Child Subcategories" class="button" onclick="location.href='gchildsubcat-list.php'" /></span></td>
</tr>
<tr>
<td height="100" align="left" valign="top" bgcolor="#f3f4f6" class="bodr">
<form name="frm" method="POST" enctype="multipart/form-data" action="" onsubmit="return validate(this)">
<input type="hidden" name="submitForm" value="yes" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" />
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2" class="paddRt14 paddBot11">
<font color="#FF0000"><strong><?php echo $_SESSION['sess_msg']; $_SESSION['sess_msg']='';?></strong></font></td>
</tr>
<tr>
<td width="23%" align="right" class="paddBot11 paddRt14"> </td>
<td width="77%" align="left" class="paddBot11"></td>
</tr>
<tr>
<td align="right" class="paddBot11 paddRt14"><strong>Category:</strong></td>
<td align="left" class="paddBot11"><select name="cat_id" id="cat_id" style="width:240px;" >
<option value="">-Select Category-</option>
<?php $catArr=$obj->query("select * from $tbl_category where status=1 order by category");
while($resultCategory=$obj->fetchNextObject($catArr)){?>
<option value="<?php echo $resultCategory->id;?>"<?php if($resultCategory->id==$result->cat_id){ ?>selected<?php } ?>><?php echo stripslashes($resultCategory->category); ?></option>
<?php }?>
</select></td>
</tr>
<tr>
<td align="right" class="paddBot11 paddRt14"><strong>Select Subcategory :</strong></td>
<td align="left" class="paddBot11" id="subcat1"><select name="subcat_id" id="subcat_id" style="width:250px;">
<option value="">Select Subcategory</option>
<option value="">Select Subcategory</option>
</select></td>
</tr>
<tr>
<td align="right" class="paddBot11 paddRt14"><strong>Select Child Subcategory :</strong></td>
<td align="left" class="paddBot11" id="childsubcat1"><select name="chsubcat_id" id="chsubcat_id" style="width:250px;">
<option value="">Select Child Subcategory</option>
</select></td>
</tr>
<tr>
<td align="right" class="paddBot11 paddRt14"><strong>Grand Child Subcategory:</strong></td>
<td align="left" class="paddBot11"><input name="gchildsubcat[]" type="text" size="36" value="" /></td>
</tr>
<tr ><td colspan="2" id="resultField"></td></tr>
<tr>
<td align="right" class="paddRt14 paddBot11"> </td>
<td align="left" class="paddBot11"> </td>
</tr>
<tr>
<td align="right" class="paddRt14 paddBot11"> </td>
<td align="left" class="paddBot11">
<a href="javascript:void(0)" id="add"> <img src="images/add.png" title="Add More" border="0" /></a>
<a href="javascript:void(0)" id="remove"> <img src="images/remove.png" title="Remove" border="0" /></a>
</td>
</tr>
<tr>
<td align="right" class="paddRt14 paddBot11"> </td>
<td align="left" class="paddBot11"> </td>
</tr>
<tr>
<td width="18%" align="right" class="paddRt14 paddBot11"> </td>
<td width="82%" align="left" class="paddBot11">
<input type="submit" name="submit" value="Submit" class="submit" border="0"/>
<input name="Reset" type="reset" id="Reset" value="Reset" class="submit" border="0" /> </td>
</tr>
</table></form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<?php include('footer.php'); ?>
</table>
</body>
</html>
Directory Contents
Dirs: 10 × Files: 414