Php statement solution for dynamic multi-logical relationship multi-condition query

Source: Internet
Author: User
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.