MOON
Server: Apache
System: Linux ip-208-109-13-31.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els4.x86_64 #1 SMP Sat Aug 31 06:58:57 UTC 2024 x86_64
User: durgeshpandey215 (1013)
PHP: 8.1.29
Disabled: NONE
Upload Files
File: /home/durgeshpandey215/www/zeeroprice.skilladders.com/admin/subcategories.php
<? require "../application_top.php";
require('protect-admin.php');
$searchkey = isset($_REQUEST['key'])? $_REQUEST['key'] : "";
if(isset($_REQUEST['subcatname'])&& $_REQUEST['subcatname'] ){
	$insertdata = array(
		'catid'=>$_REQUEST['catid'],
		'subcatname'=>$_REQUEST['subcatname']
	);
	$db->insert('subcategories',$insertdata);
	$_SESSION['msg'] = "SubCategory added successfully";
	header('location:'.$_SERVER["HTTP_REFERER"]);exit;
}

$sqlcat = "select * from categories order by catname";
$rowscat = $db->rawQuery($sqlcat);
$catArr = array();
if(count($rowscat)){
	foreach($rowscat as $rowcat){
		$catArr[$rowcat['catid']] = $rowcat['catname'];
	}
}
$pagename = "categories"; require "header.php";?>
<?
if($searchkey){
	$db->where('subcatname','%'.$searchkey.'%','like');
	}
	$db->where('catid',0,'>');
	$db->orderBy('catid','asc');
	
	//---------------Paginate BOF---------------------------------------
	$paginatetable = 'subcategories'; //table name
	$extra ="key="; //use '&' in between if more than 1 parameter
	$adjacents = 2;
	$limit = 30;		//how many items to show per page
	$db->pageLimit = $limit;
	$targetpage = $_SERVER['PHP_SELF']; //your file name  (the name of this file)
	require "../paginate.php";
	//------------------------------------------------------------------	?>
		
		<div class="w3-row">
			<div class="w3-col m12">
			<h1>Sub Categories</h1>
			
			<div style="margin:0 auto;max-width:400px;margin-bottom:20px;">
			<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" id="commonform">
			<select name="catid" class="w3-input" required>
			<option value="">Select Main Category</option>
			<?
			foreach($catArr as $key=>$val){
				?><option value="<?=$key;?>"><?=$val;?></option><?
			}
			?>
			</select>
			<input type="text" name="subcatname" class="w3-input" required placeholder="Subcategory Name"/>
			<input type="submit" name="sub" value="Add New SubCategory" class="w3-btn w3-black"/>
			</form>
			</div>
			<div style="float:right;">
			<a href="categories.php" class="w3-btn w3-blue w3-border">Go to Categories</a>
			</div>
			<?
			if($total_rows){ 
			?>	<?=$total_rows;?> Results found
				<table class="w3-table-all">
				<tr class="w3-dark-gray">
					<th>Sub Category Name</th>
					<th>Category</th>
					<th>Manage</th>
				</tr>
				<?foreach($rows as $row){
				?>
				<tr class="odd">
					<td> <?=$row['subcatname'];?></td>
					<td> <?=$catArr[$row['catid']];?></td>
					<td align="center">
						<a href="<?=HTTP_SERVER;?>admin/handle.php?action=subcatistatus&id=<?=encode($row['subcatid']);?>&newstatus=<?=($row['istatus'])? 0 : 1;?>" title="Click to <?=($row['istatus'])? "Deactivte" : "Activate";?> "><img src="<?=HTTP_SERVER;?>/images/icons/istatus-<?=($row['istatus'])? "on" : "off";?>.png" class="icons" border="0"/></a>&nbsp;
						<a href="<?=HTTP_SERVER;?>admin/subcategory-edit.php?subcatid=<?=encode($row['subcatid']);?>"><img src="<?=HTTP_SERVER;?>images/icons/edit.png" border="0" class="icons"/></a>&nbsp;
						<a href="<?=HTTP_SERVER;?>admin/handle.php?action=subcatdelete&id=<?=encode($row['subcatid']);?>" title="Click to Delete" onclick="return confirm('Are you sure you want to delete?')" class="ico del"><img src="<?=HTTP_SERVER;?>images/icons/delete.png" border="0" class="icons"/></a>
					</td>					
				</tr>
				<?}?>
				</table>
				<center><?=$pagination;?></center>
			<? } ?>
			<br/><br/>
			</div>
		</div>
<? require "../footer.php";?>