Hello, everyone! I am working on a multi-condition query system with multiple logical relationships. There are three logical relationships: AND, OR, and none. you can select from the drop-down list. I added two buttons to the page. clicking the Add button will automatically add a row of available query conditions (implemented in js). There are three specific buttons: A drop-down table of logical relationships (name: logic) to search for php statements for dynamic multi-logical relationship multi-condition query
Hello, everyone! I am working on a multi-condition query system with multiple logical relationships. There are three logical relationships: AND, OR, and none. you can select from the drop-down list. I added two buttons to the page. clicking the Add button will automatically add a row of available query conditions (implemented in js). There are three specific buttons: drop-down table of the logical relationship (name is logic), search items (such as student ID, name, nationality, name is searchitem), input text box (name is keyword) enter keywords for users. Click the delete button to delete the added condition row. My question is, how can I pass these dynamically generated drop-down lists and text box values to the PHP file? Then, an SQL query statement is generated based on the selected logical relationship (multiple possible), search items, and keywords? Thank you!
------ Solution --------------------
This logical relationship is quite complicated to write, which is too difficult for me.
The code I gave is just a reference for syntax. Organize your own ideas
PHP code
$ SQL = "SELECT * FROM student"; if (! Empty ($ _ GET ['student id ']) // If you have entered the student ID Option $ where. = "'Student id '= {$ _ GET ['student id']}"; if (! Empty ($ _ GET ['name']) {// if Yes or link $ where. = (! ($ _ GET ['and'] = '0 '))? 'OR': 'and'; $ where. = "'name' = {$ _ GET ['name']}";} $ query = $ SQL. ''. $ where;