Skip to content
Advertisement

How can I filter a generated list from a query from PHP in JS?

I have a list of files from my database. I’m looking for a way to query them. but I’m receiving an error, which is… it only display the first item if my input matches the first. This is the form

JavaScript

below is the php

JavaScript

and I have the js here

JavaScript

Advertisement

Answer

You are generating mutliple myUl divs inside while loop and you have not close </b> & </div> .Instead change your php code like below :

JavaScript

Now, you can simply your js code by using .forEach to iterate through your b tag and hide/show it when match found.

Demo Code (Added comment in code) :

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement