<?php include_once 'db.php'; $db = new DbConnect(); $finalResult = array(); //$cust_id = '2'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $cust_id = $_POST['cust_id']; $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t WHERE cust_id = '{$cust_id}' "); $row_cnt = mysqli_num_rows($result); //echo $row_cnt; $order_id_1 = array(); while ($order_id_1 = mysqli_fetch_array($result)) { /*echo $order_id_1["order_id"]; echo $order_id_1["totalprice"]; echo $order_id_1["time"]; echo $order_id_1["status"];*/ $temp = $order_id_1["order_id"]; //echo "temp"; //echo $temp; $result1 = mysqli_query($db->getDb(), "select order_id, item_id, itemname, quantity from Item NATURAL JOIN (select order_id, item_id, quantity, totalprice, cust_id, status,time from order_t NATURAL JOIN orderDetail where order_id = '{$temp}') as X "); $row_cnt = mysqli_num_rows($result1); //echo "row count"; //echo $row_cnt; $response["order_id"] = $order_id_1["order_id"]; $response["totalprice"] = $order_id_1["totalprice"]; $response["time"] = $order_id_1["time"]; $response["status"] = $order_id_1["status"]; $response["details"] = array(); while ($row = mysqli_fetch_array($result1)) { // temp user array
<?php include_once 'db.php'; $db = new DbConnect(); $response = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $order_id = $_POST['order_id']; $result = mysqli_query($db->getDb(), "UPDATE order_t SET status =1 where order_id = '{$order_id}'"); $response["success"] = 1; echo json_encode($response); } else { $response["success"] = 0; $response["message"] = "No orders found"; // echo no users JSON echo json_encode($response); }
if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = $_POST['name']; $phnum = $_POST['phnum']; $address = $_POST['address']; $email = $_POST['email']; $passwd = $_POST['passwd']; //$name = 'kshitij sharma'; //$phnum = '9662035550'; //$address = 'qwerty'; //$email = '*****@*****.**'; //$passwd = 'qwerty'; if ($name == '' || $phnum == '' || $address == '' || $email == '' || $passwd == '') { //echo 'please fill all values'; } else { $sql = "SELECT * FROM customer WHERE (email='{$email}' || phnum = '{$phnum}')"; $check = mysqli_fetch_array(mysqli_query($db->getDb(), $sql)); if (isset($check)) { //echo 'username or email already exist'; } else { $sql = "INSERT INTO customer (name,phnum,address,email,passwd,active,isAdmin,time) VALUES('{$name}','{$phnum}','{$address}','{$email}','{$passwd}','1','0',NOW())"; if (mysqli_query($db->getDb(), $sql)) { //echo 'successfully registered'; $response["success"] = 1; echo json_encode($response); } else { //echo 'oops! Please try again!'; $response["success"] = 0; $response["message"] = "No products found"; echo json_encode($response); } }
//echo $product["quantity"]; //echo "{$manag->Item_id}\n"; //echo "{$manag->quantity}\n"; } //echo "price"; $totalprice = "{$manage->totalprice}"; //echo "cust_id"; $cust_id = "{$manage->cust_id}"; //$cust_id = '9'; //$totalprice = '100' //$item_id = '6'; //$quantity = '2'; $time = date("Y-m-d H:i:s"); //echo "$time"; $query = "insert into order_t (cust_id, time, totalprice, status) values ('{$cust_id}', '{$time}', '{$totalprice}', '0' ) "; $inserted = mysqli_query($db->getDb(), $query); //echo "first query executed"; $query = "select order_id from order_t where (time = '{$time}' and cust_id = '{$cust_id}' and totalprice = {$totalprice}) "; $result1 = mysqli_query($db->getDb(), $query); //$order_id_1[] = mysqli_fetch_array($order_id_temp); //echo "order_id from query \n\n\n"; $num = mysqli_num_rows($result1); //echo "number"; //echo "$num"; //while($order_id_1[] = mysqli_fetch_array($order_id_temp)){ $order_id_1 = mysqli_fetch_array($result1); //should not contain all rows //echo "order id....."; print_r($order_id_1['order_id']); //echo sizeof($order_id_1); $oID = 0;
include_once 'db.php'; $response = array(); $db = new DbConnect(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Getting values $username = $_POST['email']; $password = $_POST['password']; //$username = '******'; //$password = '******'; //echo "hi"; //Creating sql query $sql = "SELECT * FROM customer WHERE (email='{$username}' || phnum = '{$username}') AND passwd='{$password}'"; echo "hello"; //importing dbConnect.php script //executing query $result = mysqli_query($db->getDb(), $sql); //fetching result $check = mysqli_fetch_array($result); //echo $check; //if we got some result if (isset($check)) { //displaying success //echo "success"; $response["success"] = 1; echo json_encode($response); } else { //displaying failure //echo "failure"; $response["success"] = 0; $response["message"] = "No products found"; echo json_encode($response);
<?php include_once 'db.php'; $db = new DbConnect(); $finalResult = array(); //$cust_id = '2'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $params = $_POST['params']; if ($params == 'all') { # code... $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t"); } else { if ($params == 'placed') { $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t where status = '0'"); } else { if ($params == 'approved') { $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t where status = '1'"); } else { if ($params == 'delivered') { $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t where status = '2'"); } else { $finalResult["success"] = 0; $finalResult["message"] = "no params!"; echo json_encode($response); } } } } $result = mysqli_query($db->getDb(), "select order_id, totalprice, time, status FROM order_t"); $row_cnt = mysqli_num_rows($result); //echo $row_cnt;
<?php //echo "ksh"; include_once 'db.php'; $db = new DbConnect(); $response = array(); // get a product from products table $result = mysqli_query($db->getDb(), "SELECT Item_id, itemname, price, picurl FROM Item where isAvailable = '1' "); $row_cnt = mysqli_num_rows($result); //echo $row_cnt; if (mysqli_num_rows($result) > 0) { // looping through all results // products node $response["products"] = array(); while ($row = mysqli_fetch_array($result)) { // temp user array $product = array(); $product["Item_id"] = $row["Item_id"]; $product["itemname"] = $row["itemname"]; $product["price"] = $row["price"]; $product["picurl"] = $row["picurl"]; // push single product into final response array array_push($response["products"], $product); } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { // no products found $response["success"] = 0;