Updating DB Records

Ok. I have spent 3 hours on this and I am about giving up so I decided to post here for help.
What I want to do is update records in a database. I want to click on an update button or link for the update page to open with the specific record for me to update.

  1. I have a page listing records from the database with an extra 3 columns having details, Delete , update buttons. The details button open a modal and delete does what it is supposed to do.
  2. When I click on the UPDATE button, I want another page (update-record.php) to load the specific record from the DB for me to update.
  3. I don’t want to edit all the fields of the record but just some selected fields.

I have followed these two tutorials but still


How do I get this to work?

Hi Francis,

How about passing a query parameter to the next page?

On your main list page you can add a button with a dynamic link. Add a query parameter to that URL and pass it the ID of the record you want to update:

Then on your update page you add a query manager with a variable of the same name (in this case record_id). You can then have a server connect action to a single query lookup by passing the record_id value.

–Ken

Everything you need to know about those techniques in explained in this webinar

1 Like

hello @Hyperbytes I am certainly going to spend more time on your youtube channel after this project. Unfortunately for me, I have followed this video twice but still unable to get it to work. I suspect it is because this is not exactly what I am aiming for. I want the button to load another page for the update. ( The tutorial has the update form on the same page) which is different. Can you please help me with where I need to change something?

  1. I have created the getrecord and updaterecord action files.
  2. followed step until the part you add the update container to the page. this is where I get lost.
  3. Since my flow is to get the update form on another page, how do i get the new page to select the record i want to edit.

I have tried this too. but got lost on the second step.
I am able to get the update page to open with the record ID appended to the url but When i fill the form, nothing gets updated. What makes me feel i did something wrong is the fact that, the form doesnt even show the existing data in the input area. See below. the record ID 17 loads in the address bar. but the update form does not show even the first name although the record has data in the first name column

Okay, it looks like you have everything up to sending the id as a parameter, here is the page after that (your update page):

Make sure to have a query manager added and create your parameter. My sample uses vendor_id (I believe you are using “id”:

I made a quick form with the form generator. The server action is the action I use to update the record AFTER it is loaded, modified and saved by the user. The Populate value is an action that retrieves the record.

You can see that the form created will have an update_vendor server action.

And the get_vendor action uses the vendor_id from the query manager:

If you still have trouble, you might want to post screenshots from your front end and back end code so people can see where the mistake is being made.

–Ken

I struggled with this too until @ben published a video tutorial. It is a step by step guide. https://www.youtube.com/playlist?list=PLUjqTJN3byC9kK8YZkmGwjo9nrEipl2yb

See my comments in this thread which explains the use of parameters and how they interact, it may help

  1. Create record-list-page.php - this page shows your records in a table
  2. On the above page, add BUTTON to one column to trigger the update page. add a Dynamic Attribute of a LINK and set it to update-record-page.php?id={{id}}
  3. Create two action files. a. getrecords and b. updaterecords. (ensure you add the GET variable.)
  4. Create the update-record-page.php page and add serverConnect using the getrecords action file . Then select the query id
  5. On this same update page, select App and add QueryManager and Click Define query params and select the query shown.
  6. Generate a bootstrap 4 form using the updaterecords and getrecords action files.

What did I miss in these steps that I still cant get this to work after all the help? My head is exploding…:sob::sob::sob::sob:

Hello,

I didn’t see the step here where you set the conditions in the generated query in getrecords action by specifying the GET variable as the condition.

So which part is not working exactly?
It's really not that hard...
You need one server action that's filtered by the URL parameter (already explained in the docs) which populates your form inputs.
Then you need the update record server action, which updates the data in the table, based on a hidden input ID.
Which part is not working for you exactly?

I am a bit confused on this part, you talk about a button and also a link, i assume you mean an anchor button?

Is the click action actually doing anything? Is the server action being run?