<?php include 'head.php'; include 'products.php'; $product = new Product(); $p = $product->product(); $per_page = 9; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page = 1; } // Page will start from 0 and Multiple by Per Page $start_from = ($page - 1) * $per_page; echo "<div id='items'>"; foreach ($p as $key => $product) { ?> <!--main div--> <!--- display all products--> <div class="item"> <a href="test.php?id=<?php echo $product['pId']; ?> "><img src=<?php echo $product['image']; ?> width="213" height="192" /></a><br /> <p><a href="itemDetails.php?id=<?php echo $product['pId']; ?> "><?php
$id = $_SESSION['product']['id']; if (!isset($_POST['cat_id']) || empty(trim($_POST['cat_id']))) { $product->sub_cat_id = $_SESSION['product']["sub_cat_id"]; echo " cat default,"; } else { if (!isset($_POST['sub_id']) || empty(trim($_POST['sub_id']))) { $product->sub_cat_id = $_SESSION['product']["sub_cat_id"]; echo " sub default,"; } else { $product->sub_cat_id = $_POST['sub_id']; } } if (!isset($_POST['name']) || empty(trim($_POST['name']))) { $product->sub_cat_id = $_POST['sub_id']; $name = $_POST['name']; if ($product->product($_POST['name'], $_POST['sub_id'])) { $errors[] = "unavailable name"; $_SESSION['Pname'] = "this name isnot available , aleady exsist"; header('location:../controle-edit.php?action=edit&id=' . $id . '#tabs-5'); } elseif (preg_match("/[a-zA-Z]{2,18}\$/", $name)) { //$product = new product; $product->name = $_POST['name']; echo $product->name; } else { $_SESSION['Pname'] = "Please enter valid name "; header('location:../controle-edit.php?action=edit&id=' . $id . '#tabs-5'); } } else { $product->name = $_SESSION['product']["name"]; echo " name default,"; }
include 'sub-cat.php'; $sub = new SubCategory(); include 'product.php'; $pro = new Product(); switch ($_GET['action']) { case 'selectsub': $id = $_GET['id']; $subs = $sub->sub_by_category($id); echo json_encode($subs); //var_dump($subs); break; case 'selectProduct': $name = $_GET['name']; $id = $_GET['id']; $proObj = $pro->product($name, $id); if ($proObj) { $result = array("result" => "false"); } else { $result = array("result" => "true"); } echo json_encode($result); //var_dump($proObj); break; case 'editstatus': $id = $_GET['id']; $status = $_GET['status']; //echo "id = ".$id."status = ".$status; $pro->status = $status; $product_id = $pro->updateStatus($id); echo $product_id;
} else { if (!isset($_POST['sub_id']) || empty(trim($_POST['sub_id']))) { $product->sub_cat_id = $_SESSION['product']["sub_cat_id"]; echo " sub default<br>"; } else { $product->sub_cat_id = $_POST['sub_id']; $id = $_POST['sub_id']; } //end of check for sub -id } //end of check for cat - id if (!isset($_POST['name']) || empty(trim($_POST['name']))) { $product->name = $_SESSION['product']["name"]; echo " name default<br>"; } else { if ($product->product($_POST['name'], $id)) { $_SESSION['Pname'] = "this name isnot available , aleady exsist"; header('location:../controle-edit.php?action=edit&id=' . $id . '#tabs-5'); } else { if (preg_match("/[a-zA-Z]{2,18}\$/", $_POST['name'])) { $product->name = $_POST['name']; echo $product->name; } else { $_SESSION['Pname'] = "Please enter valid name "; header('location:../controle-edit.php?action=edit&id=' . $id . '#tabs-5'); } } } //end of check for name if (file_get_contents($_FILES['image']['tmp_name']) != '') { echo "here in image<br>";