The existing form is intended to correct the data entered in the Postgres database. Data call, correction and update of records in the database.
After calling and filling the array elements with data from Postgres
<?php> $qexist = "SELECT test.tb.id_bld, test.tb.street, test.tb.bld_no, FROM test.tb WHERE test.tb.street = '$street' AND test.tb.bld_no = '$bld_no' "; $ress = pg_query($qexist); while ($row = pg_fetch_array($ress)) { $val[11] = $row[11]; $val[12] = $row[12]; $val[13] = $row[13]; $val[14] = $row[14]; } ?> inserting them into form fields and correcting data
<tr> <td> <label for="Shop">Shop:</label> </td> <td> <input type="text" name="shop" value="<?php echo $val[11] ?>"> </td> </tr> <tr> <td><label for="Services">Services:</label> </td> <td><input type="text" name="services" value="<?php echo $val[12] ?>"> </td> </tr> <tr> <tr> <td> <label for="Category of building">Investment Category:</label> </td> <td> <input type="text" name="category" value="<?php echo $val[13] ?>"> </td> </tr> <tr> <td> <label for="Manager_id">Manager ID</label> </td> <td> <input type="text" name="id_manager" value="<?php echo $val[14] ?>"> </td> </tr> <input type="hidden" name="timestamp" value="<?php echo date ('Ymd H:i:s')?>"> <tr> <td> <input type="submit" onClick="return nodata(this.form)" name="query" value="Query"> </td> <td> <input type="submit" onClick="return nodata(this.form)" name="update" value="Update" id="upDate"> </td> <td> <input type="reset" name="reset" value="Clear It"> </td> </tr> sending corrected data back to the database
if (isset($_POST['update'])) { $data = array( 'shop' => $val[11], 'services' => $val[12], 'category' => $val[13], 'id_manager' => $val[14] ); $elem = $_POST; foreach($elem as $key => $value) unset($elem['update']); $res = pg_update($dbconn, 'test.tb', $elem, $data); if ($res) { echo "Updated: $res\n"; } else { echo "Data not sent\n"; } } the data of the last query remains in the elements of the $val[] array, and given that these elements are rigidly tied to the fields of the form value="<?php echo $val[x] ?> , this data continues to be in the field, despite the unset ( $elem ['update'] ); and of course they are not removed from the fields with the type=reset in the standard version. Please tell me which code attached to the Reset button can clear (reset values) the contents of the array elements and then the previous values will disappear from the form without all its special cleaning.
If it is possible to clear the array immediately after sending the data with the Update button, adding the function of clearing (resetting the data) of the array to unset , it would be ideal not to clutter the form with buttons. thank