public function updateItem($itemid, $itemcode, $itemname, $itemtype, $prices, $pricem, $pricel, $image, $itemsettings) { global $db; $sql = "SELECT * FROM `" . TBL_ITEMS . "` WHERE `itemid` = '{$itemid}'"; $record = $db->query_first($sql); if ($record) { $data['itemcode'] = $itemcode; $data['itemname'] = $itemname; $data['itemtype'] = $itemtype; $data['prices'] = $prices; $data['pricem'] = $pricem; $data['pricel'] = $pricel; $data['image'] = $image; $data['itemsettings'] = $itemsettings; $db->update(TBL_ITEMS, $data, "`itemid` = {$itemid}"); $message['text'] = __('Item Updated successfully'); return $message; } else { return addNewItem($itemcode, $itemname, $itemtype, $prices, $pricem, $pricel, $image, $itemsettings); } }
$newAddressData[0] = $_SESSION['currentUserID']; $newAddressData[1] = filter_input(INPUT_POST, 'selected_address_group'); $newAddressData[2] = filter_input(INPUT_POST, 'fullname'); $newAddressData[3] = filter_input(INPUT_POST, 'email'); $newAddressData[4] = filter_input(INPUT_POST, 'address'); $newAddressData[5] = formatPhone(stripDownPhone(filter_input(INPUT_POST, 'phone'))); $newAddressData[6] = filter_input(INPUT_POST, 'website'); $newAddressData[7] = filter_input(INPUT_POST, 'birthday'); $errors = validateNewItem($newAddressData); if (count($errors) == 0) { $newAddressData[8] = uploadImage(); if (empty($newAddressData[8])) { $errors[] = 'Image could not be uploaded'; $results = 'Empty Image'; } if (addNewItem($newAddressData)) { $results = 'New item added to address book'; } else { $results = 'Item was not Added'; } } else { $results = 'Errors found'; } } //var_dump($newAddressData); ?> <?php if (isset($errors) && count($errors) > 0) { ?> <ul>
} if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql = "select * from delete_this_table where data=" . $get_user_id; $user_cart = NULL; if ($result = mysqli_query($con, $sql)) { $resultArray = array(); $row = $result->fetch_object(); $user_cart = $row->array; } $new_cart_array = " "; if (strcmp($operation, "delete") == 0) { $new_cart_array = deleteOldItem($user_cart, $name); } else { $new_cart_array = addNewItem($user_cart, $name); } mysqli_close($con); echo json_encode($returnValue); $dbhost = 'localhost:8080'; $dbuser = '******'; $dbpass = '******'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if (!$conn) { die('Could not connect: ' . mysql_error()); } $sql = sprintf("UPDATE delete_this_table SET array = '%s' WHERE data = '%s'", $new_cart_array, $get_user_id); mysql_select_db('strum'); $retval = mysql_query($sql, $conn); if (!$retval) { die('Could not enter data: ' . mysql_error());
} //Finds an item based on inventory id and serial number and returns the record. function findItem($serial, $invId, $database) { $sql_query = 'SELECT * FROM ITEM WHERE inventory_id="' . $invId . '" AND serial_number="' . $serial . '"'; return mysql_query($sql_query); } //Update an item record with values provided function updateItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database) { $sql_query = "UPDATE ITEM SET item_name=\"" . $item . "\",value=" . $value . ",model='" . $model . "',manufacturer=\"" . $man . "\",category=\"" . $cat . "\",item_purchase_date=\"" . $pdate . "\",notes=\"" . $notes . "\" WHERE inventory_id=" . $invId . " AND serial_number=" . $serial; mysql_query($sql_query); } //Checks method type passed and calls appropriate function if ($method == "addItem") { addNewItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database); } else { if ($method == "findItem") { $result = findItem($serial, $invId, $database); if (mysql_num_rows($result) == 1) { //Gathers table fields to insert into json response while ($row = mysql_fetch_array($result)) { echo '{"item":{'; echo '"itemName":"' . $row['item_name'] . '",'; echo '"value":"' . $row['value'] . '",'; echo '"model":"' . $row['model'] . '",'; echo '"man":"' . $row['manufacturer'] . '",'; echo '"cat":"' . $row['category'] . '",'; echo '"pdate":"' . $row['item_purchase_date'] . '",'; echo '"notes":"' . $row['notes'] . '"'; echo '}}';
$action = $_REQUEST['action']; /* Ajax services */ if ($action == "addNewAttr") { $newAttr = $_REQUEST['addNewAttr']; $qry = "insert into attributes values (null,\"" . $newAttr . "\");"; //echo "QRY ".$qry; $res = executeQuery($qry); //echo "DONE"; echo allAttributes(); } /* Ajax services end*/ /* Submission, action and URL redirection */ $action = $_REQUEST["action"]; if ($action == "addNewItem") { var_dump($_REQUEST); addNewItem(); } if ($action == "updateItem") { var_dump($_REQUEST); updateItem(); } /* Submission, action and URL redirection - end*/ function allClassifications() { $allClasses = executeQuery("SELECT * FROM classification_base "); $classArray = array(); $i = 0; $classStr = ""; while ($row = mysql_fetch_assoc($allClasses)) { $classStr = $classStr . $row['class_id'] . "&" . $row['class_name'] . "&" . $row['parent_classid'] . ";"; // echo "<br>CLASS ID ".$row['class_id'];