/** * @name update * @description update an item * @param int $id * @param string $name * @return mixed */ private function update($id, $name) { $item = new Items(); if ($item->update($id, $name)) { return $this->response('', 'Item has been updated', false); } return $this->response('', "Could not update the item {$id}", true); }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); // load the items class require_once '../classes/concertClass.php'; $response = array('error' => true, 'message' => ''); if (isset($_POST['id']) && isset($_POST['name'])) { $id = $_POST['id']; $name = $_POST['name']; $items = new Items(); // update the item if ($items->update($id, $name)) { $response['error'] = false; $response['message'] = 'Item has been updated'; } else { $response['message'] = 'Could not update the item'; } } else { $response['message'] = 'Missing id value'; } // json response echo json_encode($response);
$upError[] = "Type not found"; } elseif (strlen($upTitle) < 1) { $upError[] = "enter title"; } elseif (strlen($upGenre) < 1) { $upError[] = "enter genre"; } elseif (strlen($upDescription) < 1) { $upError[] = "enter description"; } elseif (strlen($upPrice) < 1) { $upError[] = "enter price"; } elseif (strlen($upRP) < 1) { $upError[] = "enter rentperiod"; } elseif (!isset($upStatus)) { $upError[] = "status not found"; } else { $upI = new Items($upType, $upNo, $upTitle, $upGenre, $upDescription, $upPrice, $upRP, $upStatus); $upI->update(); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <title>Inventory</title>