HTML and PHP
I have tried just making a simple editing table for people to easily edit colums and I am using newest version of tabledit and the form just wont post to my update file.
<table id = "data_table" class="table table-bordered table-striped" >
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Item Name</th>
<th scope="col">Originl Barcode #</th>
<th scope="col">Compnay Name</th>
<th scope="col">Location</th>
<th scope="col">Details On Item</th>
<th scope="col">Barcode Image</th>
<th scope="col">inventory Count</th>
<th scope="col">Labeled Barcode</th>
<th scope="col">Actions</th>
</tr>
</thead>
<?php
include 'serverconn.php';
$itemid = '';
$sql = "SELECT id, ItemName, ItemBarcode, CompanyName, OurBarcode,
DetailsOnItem, barcodeimg, count, combindedBarcode
FROM items";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$itemid = $row['id'];
?>
<tbody>
<tr id="<?php echo $row['id']; ?>" >
<th> <?php echo $row['id']; ?></th>
<td data-column='ItemName' id="ItemName"><?php echo $row['ItemName']; ?></td>
<td data-column='ItemBarcode' id="ItemBarcode"><?php echo $row['ItemBarcode']; ?></td>
<td data-column='CompanyName' id="CompanyName"><?php echo $row['CompanyName']; ?></td>
<td data-column='OurBarcode' id="OurBarcode"><?php echo $row['OurBarcode']; ?></td>
<td data-column='DetailsOnItem' id="DetailsOnItem"><?php echo $row['DetailsOnItem']; ?></td>
<td data-column='barcodeimg' id="barcodeimg"><image src='<?php echo $row['barcodeimg']; ?>'></img></td>
<td data-column='count' id="count"><?php echo $row['count']; ?></td>
<td data-column='combindedBarcode' id="combindedBarcode"><?php echo $row['combindedBarcode']; ?></td>
</tr>
<?php
}
?>
</tbody>
<?php
} else {
echo 'No results found';
}
$conn->close();
?>
</table>`
Java Script File
$('#data_table').Tabledit({
url:'update.php',
editButton: false,
deleteButton: false,
inputClass: 'form-control input-sm',
eventType:'click',
identifier: false,
autoFocus: true,
columns:{
identifier:[0, 'id'], editable: [[1, 'ItemName'], [2, 'ItemBarcode'],
[3, 'CompanyName'],
[4, 'OurBarcode'],
[5, 'DetailsOnItem'],
[7, 'count'],
]
},
onSuccess:function(data, textStatus, jqXHR){
},
});
I have just been looking up things to fix the problem. Its not saving my edits. I will share what my update file looks like rq
<?php
//action.php
$connect = mysqli_connect('localhost', 'root', '', 'database_solarmax');
$input = filter_input_array(INPUT_POST);
$itemname = htmlspecialchars(mysqli_real_escape_string($conn, $input['ItemName']));
$itembarcode = htmlspecialchars(mysqli_real_escape_string($conn, $input['ItemBarcode']));
$companyname = htmlspecialchars(mysqli_real_escape_string($conn, $input['CompanyName']));
$ourbarcode = htmlspecialchars(mysqli_real_escape_string($conn, $input['OurBarcode']));
$detailsonitem = htmlspecialchars(mysqli_real_escape_string($conn, $input['DetailsOnItem']));
$inventoryCount = htmlspecialchars(mysqli_real_escape_string($conn, $input['count']));
if($input["action"] === 'edit')
{
$query = "UPDATE `items`
SET `ItemName`= ' ".$input['ItemName']. "',
`ItemBarcode` =' ".$input['ItemBarcode']." ',
`CompanyName`=' ".$input['CompanyName']." ',
`OurBarcode` = '".$input['OurBarcode']."',
DetailsOnItem='".$input['DetailsOnItem']."',
WHERE id= '".$input['id']."'";
mysqli_query($connect, $query);
}
if($input["action"] === 'delete')
{
$query = "DELETE FROM items
WHERE id = '".$input["id"]."' ";
mysqli_query($connect, $query);
}
echo json_encode($input);
?>
But I have tried a numerious amount of things from changing my php update file and also messed with the javascript just wont auto save like it supposed to. :/