<?php include 'sets.php';?>
<?php
$superuser="0";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Webadmin <?php echo $domain ?></title>
<?php include 'codes.php';?>
</head>
<body>

<?php include 'navbar.php';?>
    
<div class="container">
<div class="frame">
<div class="frametitles flist"><?php echo $adminsearch ?></div>
<div class="framein">

<?php 
$resultsc = $mysqli->query("SELECT id FROM sections WHERE lang_id=$lang");
$srows = mysqli_num_rows($resultsc);
?>

<?php
if  (isset($_POST['changesection'.$_REQUEST['id']])) {
$section_id = $mysqli->real_escape_string(stripslashes($_REQUEST['section_id']));
$category_id = $mysqli->real_escape_string(stripslashes($_REQUEST['category_id']));
$search = $mysqli->real_escape_string(stripslashes($_REQUEST['search']));
$mysqli->query("UPDATE items SET section_id='$section_id' WHERE insert_id='{$_REQUEST['id']}'"); 
?>
<meta http-equiv="refresh" content="0;URL=list-items.php?catid=<?php echo $category_id ?>&amp;secid=<?php echo $section_id ?>">    
<?php } ?>

<div>
<ul class="nospace">

<?php
$search = $mysqli->real_escape_string(stripslashes($_REQUEST['search'])); 

// split on + 
$parts = explode(" ",$search);
foreach ($parts as $section)
{
	 if (!empty($querystring)) $querystring .= " AND ";
// split words 
    $keywords = explode(" ",trim($section));
    foreach ($keywords as $issue)
    {
    if (!empty($searchstring)) $searchstring.= " AND ";
    $searchstring .= "name LIKE '%{$issue}%' OR description LIKE '%{$issue}%' OR details LIKE '%{$issue}%' OR text LIKE '%{$issue}%' OR url LIKE '%{$issue}%' OR email LIKE '%{$issue}%' OR code LIKE '%{$issue}%' OR script LIKE '%{$issue}%'";
    }
    $querystring .= " ($searchstring) ";
    $searchstring = '';
	
}
?>

<?php if ($_REQUEST['search']) { ?>

<?php 
$result10 = $mysqli->query("SELECT * FROM items WHERE ({$querystring}) GROUP BY insert_id ORDER BY priority");
$nrresults = mysqli_num_rows($result10);
while($row = $result10->fetch_array()) {
$count++;
$itemid=$row['insert_id'];
			
$result = $mysqli->query("SELECT * FROM items WHERE insert_id='$itemid' AND lang_id=$lang");
$row = $result->fetch_array();
$id=$row['insert_id'];
$submitid=$row['insert_id'];
$lang_id=$row['lang_id'];
$category_id=$row['category_id'];
$section_id=$row['section_id'];
$secid=$row['section_id'];
$name=$row['name'];
$description=$row['description'];
$details=$row['details'];
$text=$row['text'];
$code=$row['code'];
$url=$row['url'];
$email=$row['email'];
$script=$row['script'];
$price=$row['price'];
$offerprice=$row['offerprice'];
$weight=$row['weight'];
$unit=$row['unit'];
$image=$row['image'];
$file=$row['file'];
$new=$row['new'];
$available=$row['available'];
$promote=$row['promote'];
$size=$row['size'];
$color=$row['color'];
$showpage=$row['showpage'];
$publish=$row['publish'];
$priority=$row['priority'];
$date=$row['date'];

$result1 = $mysqli->query("SELECT insert_id, name, type FROM categories WHERE insert_id=$category_id AND lang_id=$lang");
$row = $result1->fetch_array(); 
$catid=$row['insert_id'];
$cat=$row['name'];
$typec=$row['type'];
?>
<?php include 'itemin.php';?>
<?php }?>

<strong><?php echo $nrresults ?></strong> <?php echo $adminitems ?>
<?php }?>

</ul>
</div>

</div>
</div>
</div>

<?php include 'menudown.php';?>

</body>
</html>