What is the best practice for displaying a list of items that can be modified via HTTP POST (PHP + MySQL)

I am creating an inventory system for myself that contains a list of items (with a description, a counter, the last date used, etc.), which also contains the status for the item. At the most basic level, I list all the elements from the MySQL query (SELECT * FROM Items) along with my status in the SELECT HTML FORM element (int datatype, 0/1/2 status indicator).

I want to be able to update any item in this list without analyzing every item that has been specified, and do a comparison with the contents of the SQL server. I would suggest that this is not the best practice, and the best way to achieve this is to make a list of items that are changing and sent via HTTP POST. It's right? What would be the best way to achieve this?

+5
source share
1 answer

Use Ajax. Clean and simple. A quick implementation way is to use jQuery.

<select id="target">
    <option value="option1" selected="selected">Option 1</option>
    <option value="option2">Option 2</option>
  </select>

Javascript

$('#target').change(function () {
$.ajax({

    type: "POST",
    url: "page.php",
    data: 'id=something' ,
    success: function (msg) {
        //after php response
    }
});

});

See change and ajax

+1
source

All Articles