Home > Article > Backend Development > Multiple condition combination query (1)_PHP tutorial
Usually when we develop the system, we will definitely not be short of query terms. However, often one condition cannot meet the user's requirements. At this time, we should set up multiple conditions to combine, so that users can more conveniently select the query conditions when querying. Quickly find the records they satisfy.
Now we assume that we develop a customer order system for a watch company. There are customer order numbers, categories, names, quantities, prices and other information. We will not list the information one by one here. Orders The table is as follows:
Order number (ID) Category (TYPE) Name (NAME) Quantity (QTY) Price (PRICE)
001 Movement Movement 1 100 150
001 Case Case 1 1000 60
001 Watch strap 1 500 70
002 Movement movement 2 200 40
002 Case Case 2 300 53
002 Watch strap 2 400 46
Now we imagine that Build a query system that allows users to quickly query based on order number, category, price, or a combination thereof. The code is as follows:
The following part is a form that displays query conditions
$linkstr=mysql_connect("localhost","root","sa"); > ?>