changing the DOM after accessing a database

144 Views Asked by At

i'm using the PDO library in php to access a database and return some values into a table which need to be shown when the user first opens the webpage,

after this I want to implement a filter option, so that the user can input some data in a form field and the data shown is updated according to the filters set by the user.

I don't know how to update the DOM in this case, would it be possible to update the DOM using Jquery so that only the new values are shown in the table, or do i need to redirect to a new page/reconstruct my table with a full request/response cycle.

thank you for your help in anycase.

1

There are 1 best solutions below

0
On

If I understand correctly, you want to output the data from the result of your MySQL query as a table, and then having a search bar which will filter the output table according to the search bar. What I would do is first use the data to generate a table and give it a css class. For the search bar you can use form or event listener to process apply your filter from the value in the search bar. For example you can loop the rows of the table and check if a column contain a substring of the search bar value(as an example, check with whatever criteria you prefer) and just add a css value display: hidden to the row, or restructure the table, there are many ways of doing it.