MySQL Forums
Forum List  »  PHP

Re: Update returned records with HTML form
Posted by: Peter Brawley
Date: September 30, 2020 10:55AM

This isn't social media. Code is text. Urls of unknown provenance pose risks, IAC text in images is often hard to read.

In the page displayimg the result record, you want a form with an html input element for a tracking number, is that correct? It'll need to be initialised to an empty string.

To add that element to the the relevant row of the database table ...

(i) the page will need the primary key of the competition table row thaty it's displaying

(ii) the competition table will need a column defined for the tracking number

(iii) the form will need a submit element such that when the user enters the tracking # and submits, the action page can issue an Update command to MySQL; assuming the form element and the column name are "tracknum" and the PK is competitionid, the update code would be something like ...

$compid = $conn->escape_string( $_POST['competitionid'] );
$trackno = $conn->escape_string( $_POST['tracknum'] );
$qry = "update competition set tracknum=$trackno where competitionid=$compid;
$res = $conn->query( $qry ) or error_handler( $conn, $res );

Note the above requires the app to have an error_handler() function that takes $conn and $res vars as params. A better alternative would be to put the Update in a transaction block that can be re-entered in case of a deadlock &c.

Note too that your text "that search criteria" is ungrammatical, you need "that search criterion".



Edited 1 time(s). Last edit at 09/30/2020 10:58AM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Update returned records with HTML form
September 30, 2020 10:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.