Time for action – updating an existing item
When
updating a new item, the special UPDATE
SQL keyword can be used. The following code updates an existing item:
db_execute(" UPDATE `plugin_cbEnhancedInfo_dataTable` Set hostId=$s_dataHostId, longitude='$s_dataLongitude', latitude='$s_dataLatitude', contactAddress='$s_dataContactAddress', additionalInformation='$s_dataAdditionalInformation' WHERE Id='$dataId' ");
As with the creation of a new item, this code is also missing from the file. You can enter it after the comment in the following section:
if ( (isset ($_POST['contactAddress'])) && (isset ($_POST['update_component_import']) ) ) { /* Add Update statements here */ }
Let's look how the db_execute
command will look with real data. Open a MySQL CLI and execute the following statement. You may have to change the Id
to match your database data from the SELECT *
statement in the previous section:
mysql> UPDATE `plugin_cbEnhancedInfo_dataTable` Set ...