exit; } if (isset($_GET['status']) && $_GET['status'] != '') { $status = $_GET['status']; $sql2 = " AND od_status = '{$status}'"; $queryString = "&status={$status}"; } else { $status = ''; $sql2 = ''; $queryString = ''; } // for paging // how many rows to show per page $rowsPerPage = 10; $sql = "SELECT o.od_id, o.od_shipping_first_name, od_shipping_last_name, od_date, od_status,\r\n SUM(pd_price * od_qty) + od_shipping_cost AS od_amount\r\n\t FROM tbl_order o, tbl_order_item oi, tbl_product p \r\n\t\tWHERE oi.pd_id = p.pd_id and o.od_id = oi.od_id {$sql2}\r\n\t\tGROUP BY od_id\r\n\t\tORDER BY od_id DESC"; $result = dbQuery(getPagingQuery($sql, $rowsPerPage)); $pagingLink = getPagingLink($sql, $rowsPerPage, $queryString); $orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled'); $orderOption = ''; foreach ($orderStatus as $stat) { $orderOption .= "<option value=\"{$stat}\""; if ($stat == $status) { $orderOption .= " selected"; } $orderOption .= ">{$stat}</option>\r\n"; } ?> <p> </p> <form action="processOrder.php" method="post" name="frmOrderList" id="frmOrderList"> <table width="100%" border="0" cellspacing="0" cellpadding="2" class="text">
/** * entry point */ function init() { try { $statuses = $_POST["statuses"]; $sort = ""; $filterArr = array(); $filter = ""; $paging = ""; $pagingStatus = null; $query = ""; $html = ""; //error_log(urldecode($_POST["statuses"])); if (isset($statuses)) { //statuses => array $statuses = json_decode(urldecode($statuses)); foreach ($statuses as $key => $value) { switch ($value->action) { case "paging": $pagingStatus = $value; break; case "filter": $filter .= getFilterQuery($value, $filter); break; case "sort": $sort = getSortQuery($value); break; } } //connect to SQLite database $db = new PDO("sqlite:jplist.db"); //increases sqlite performance by turning syncing off $db->exec("pragma synchronous = off;"); //count database items for pagination $query = "SELECT count(*) FROM Item " . $filter . " " . $sort; $count = $db->query($query)->fetchColumn(); //init pagination query if ($pagingStatus) { $paging = getPagingQuery($pagingStatus, $count); } //init query with sort and filter $query = "SELECT title, desc, img, likes, keyword1, keyword2 FROM Item " . $filter . " " . $sort . " " . $paging; //select items $items = $db->query($query); foreach ($items as $item) { $html .= getHTML($item); } //init array for json data //$json_arr = array("html" => utf8_encode($html), "data" => array("count" => $count), "query"=> $query); //print html echo getHTMLWrapper($html, $count); //close the database connection $db = NULL; } } catch (PDOException $ex) { print 'Exception: ' . $ex->getMessage(); } }
/** * entry point */ function init() { try { //connect to database $db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD); $preparedParams = array(); $statuses = $_POST["statuses"]; $json = ""; $pagingStatus = null; $filter = ""; $sort = ""; $query = ""; $counter = 0; if (isset($statuses)) { //statuses => array $statuses = json_decode(urldecode($statuses)); foreach ($statuses as $key => $value) { switch ($value->action) { case "paging": $pagingStatus = $value; break; case "filter": $filter .= getFilterQuery($value, $filter, $preparedParams); break; case "sort": $sort = getSortQuery($value, $preparedParams); break; } } } //count database items for pagination $query = "SELECT count(*) FROM Item " . $filter . " " . $sort; if (count($preparedParams) > 0) { $stmt = $db->prepare($query); //error_log(print_r($preparedParams, true)); $stmt->execute($preparedParams); $count = $stmt->fetchColumn(); } else { $count = $db->query($query)->fetchColumn(); } //init pagination query if ($pagingStatus) { $paging = getPagingQuery($pagingStatus, $count, $preparedParams); } //init query with sort and filter $query = "SELECT title, description, image, likes, keyword1, keyword2 FROM Item " . $filter . " " . $sort . " " . $paging; if (count($preparedParams) > 0) { $stmt = $db->prepare($query); $stmt->execute($preparedParams); $items = $stmt->fetchAll(); } else { $items = $db->query($query); } $json .= "["; foreach ($items as $item) { if ($counter > 0) { $json .= ","; } $json .= json_encode($item); $counter++; } $json .= "]"; //print json echo getWrapper($json, $count); //close the database connection $db = NULL; } catch (PDOException $ex) { print 'Exception: ' . $ex->getMessage(); } }
<?php if (!defined('WEB_ROOT')) { exit; } $productsPerRow = 2; $productsPerPage = 4; //$productList = getProductList($catId); $children = array_merge(array($catId), getChildCategories(NULL, $catId)); $children = ' (' . implode(', ', $children) . ')'; $sql = "SELECT pd_id, pd_name, pd_price, pd_thumbnail, pd_qty, c.cat_id\r\n\t\tFROM tbl_product pd, tbl_category c\r\n\t\tWHERE pd.cat_id = c.cat_id AND pd.cat_id IN {$children} \r\n\t\tORDER BY pd_name"; $result = dbQuery(getPagingQuery($sql, $productsPerPage)); $pagingLink = getPagingLink($sql, $productsPerPage, "c={$catId}"); $numProduct = dbNumRows($result); // the product images are arranged in a table. to make sure // each image gets equal space set the cell width here $columnWidth = (int) (100 / $productsPerRow); ?> <table width="100%" border="0" cellspacing="0" cellpadding="20"> <?php if ($numProduct > 0) { $i = 0; while ($row = dbFetchAssoc($result)) { extract($row); if ($pd_thumbnail) { $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail; } else { $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png'; } if ($i % $productsPerRow == 0) { echo '<tr>';