Advertisement
Monzi

Untitled

Feb 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.07 KB | None | 0 0
  1. $sql = ("select * from inventory");
  2.         $sqlQuery = $db->query($sql) or die($db->error);
  3.         $sqlQuery->num_rows;
  4.         while($sqlFetch = $sqlQuery->fetch_object()){
  5.             echo "
  6.                 <div class='modal fade' id='{$sqlFetch->id}' tabindex='-1' role='dialog' aria-labelledby='editInvLabel'>
  7.                     <div class='modal-dialog' role='document'>
  8.                         <div class='modal-content'>
  9.                             <div class='modal-header'>
  10.                                 <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
  11.                                 <h4 class='modal-title' id='editInvLabel'>Edit</h4>
  12.                             </div>
  13.                             <form method='post' role='form'>
  14.                                 <div class='modal-body'>
  15.                                     <div class='form-group'>
  16.                                         <label for='InputEditName'>Name</label>
  17.                                         <input type='text' class='form-control' id='InputEditName' placeholder='Name of the item' value='{$sqlFetch->name}' name='InputEditName'>
  18.                                     </div>
  19.                                     <div class='form-group'>
  20.                                         <label for='InputEditType'>Type</label>
  21.                                         <input type='text' class='form-control' id='InputEditType' placeholder='Type of item' value='{$sqlFetch->type}' name='InputEditType'>
  22.                                     </div>
  23.                                     <div class='form-group'>
  24.                                         <label for='InputEditStock'>Stock</label>
  25.                                         <input type='text' class='form-control' id='InputEditStock' placeholder='Amount in stock' value='{$sqlFetch->stock}' name='InputEditStock'>
  26.                                     </div>
  27.                                     <div class='form-group'>
  28.                                         <label for='InputEditPrice'>Price</label>
  29.                                         <input type='text' class='form-control' id='InputEditPrice' placeholder='Price per item' value='{$sqlFetch->price}' name='InputEditPrice'>
  30.                                     </div>
  31.                                     <div class='form-group'>
  32.                                         <label for='InputEditSets'>Sets</label>
  33.                                         <input type='text' class='form-control' id='InputEditSets' placeholder='Example Prime A, B, C or D for sorting' value='{$sqlFetch->sets}' name='InputEditSets'>
  34.                                         <span id='helpBlock' class='help-block'>
  35.                                             A is for parent blueprints<br>
  36.                                             B is for Neuroptics<br>
  37.                                             C is for Chassis<br>
  38.                                             D is for Systems
  39.                                         </span>
  40.                                     </div>
  41.                                 </div>
  42.                                 <div class='modal-footer'>
  43.                                     <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
  44.                                     <button type='submit' class='btn btn-primary' name='SubmitEditForm'>Save changes</button>
  45.                                 </div>
  46.                             </form>
  47.                         </div>
  48.                     </div>
  49.                 </div>
  50.             ";
  51.             if(isset($_POST['SubmitEditForm'])){
  52.                 $name = $db->real_escape_string($_POST['InputEditName']);
  53.                 $type = $db->real_escape_string($_POST['InputEditType']);
  54.                 $stock = $db->real_escape_string($_POST['InputEditStock']);
  55.                 $price = $db->real_escape_string($_POST['InputEditPrice']);
  56.                 $sets = $db->real_escape_string($_POST['InputEditSets']);
  57.                 $sql = "update inventory set name = '{$name}', type = '{$type}', stock = '{$stock}', price = '{$price}', sets = '{$sets}'";
  58.                 $sql .= " where id = {$id}";
  59.                 $db->query($sql) or die($db->error);
  60.                 header('location:index.php?page=inventory');
  61.             }
  62.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement