php - MySQL updating records, but page display not showing new data -


I am writing an application for CRUD user details. I extract the page with a query in the user table - and use the data to populate different form elements in the page (and to check duplicates). All form submissions get deposited on the same page.

Works as expected to add, delete, and modify records - but the kicker is that the displayed data on the page is not updated once the change has been submitted - To see relevant changes, I have to see the page again.

  Try {$ user_sql = "select user_id, user_firstname, user_surname, user_email, user type of user"; $ User_stmt = $ db- & gt; Ready ($ user_sql); $ User_stmt- & gt; Executed (); $ User_data = $ user_stmt- & gt; Get All (PDO :: FETCH_NAMED); $ I ++; } Hold (PDOException $ e) {resonant "error: user data can not be retrieved from data base"; } / * * DELETE USER * / if (isset ($ _ POST ['deleteUser'])) {$ _SESSION ['deleteUser'] = true; } {$ DeleteRange = implode (',', $ _ POST ['deleteUser']}} {ifr (= $ _ POST ['submitDeleteUserConfirm'])) {// process query if ($ _ POST ['deleteUserConfirm'] == 'yes']); Delete $ sql = 'Delete user, where id_user in ('. $ Dealer range. ')'; {$ Q = $ db- & gt; Try ($ deleteSql); $ Q- & gt; Executed (); } Hold (PDOException $ e) {echo & lt; P & gt; system error: '. $ E- & gt; incoming message (). '& Lt; / P & gt; '; }} // Once processed upon confirmation: // Delete session trigger to hide confirmation form (if ($ _ session ['deleted user'])) {without set ($ _ session ['delete' user ']); }} If (isset ($ _ session ['deleteUser'])) {? & Gt; & Lt; Fieldet class = "radialbox" & gt; & Lt; Story & gt; Confirm & lt; / Narrative & gt; & Lt; Div & gt; & Lt; Label = "deleteUserYes" & gt; Yes & lt; / Labels & gt; & Lt; Input type = "radio" class = "radio" name = "delete device provider" id = "deleteUserYes" value = "yes" & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; Label = "deleteUserNo" & gt; No & lt; / Label & gt; & Lt; Input type = "radio" class = "radio" name = "delete device provider" id = "deleteUserNo" value = "no" checked & gt; & Lt; / Div & gt; & Lt; Input type = "submit" name = "submitDeleteUserConfirm" value = "confirm" & gt; & Lt; / Fieldset & gt; & Lt ;? Php} // small function in the form of output to all elements of the Ererem $ checkbox $ delStudentRollOpts = array ('key' = & gt; 'user', 'sticky' = & gt; true, 'data' = & gt; array 'Value' = & gt; $ user_data, # data from #swrap start - not being updated on page refresh / form 'name' = & gt; array ('user_firstname', 'user_surname')), ' Element_name '= & gt; 'Aile (' title '= & gt; array (' title '= & gt;' & amp; nbsp; ',' name '= & gt; deleteUser', 'index' = & gt; delisted ral_ '. $ N, 'type' = & gt;; 'id_user'))); Echo $ GA_form- & gt; Generate ($ delStudentRollOpts); Echo '& lt; Input type = "submit" class = "submit" name = "submit user_ '. $ N." "Value =" Delete "& gt; '; echo & lt; / fieldset & gt;'; echo '& lt; / form & gt;';  

This work is in progress Therefore, it requires a lot of refactoring ...

User's perspective:

1: Enter new data

2: Submit form < / P>

3: Check DB from MySQL console - New data entered

4: No new data is shown

5: Go to page again - New Data appears (refreshing the duplicate value of the key Will trigger an error in the sentence)

Any ideas about what is happening to someone? At the moment I am doing the idea of ​​redirecting back to the page with a header

  if (form_submitted) {update_database ()} fetch_data (); & lt ; Forms & gt; & lt; / Forms & gt;  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -