We can use the Extract () function, such as adding extract ($_post) to the front of the receiving page script, extract ($_get), such statements, and exporting several super variable array values for the form processing, as shown in the following code:
@extract (I_addslashes ($_post), extr_overwrite); @extract (I_addslashes ($_get), extr_overwrite); @extract (I_addslashes ($_cookie), extr_overwrite); @extract (I_addslashes ($_session), extr_overwrite);
|
Let's look at a script example that uses extract to export to a normal variable
<?php Converts the variables obtained by the $_get and $_post arrays into normal variables so that the variable names are displayed directly Extract ($_get);
echo "Hello, $username $age"; ?> <form action= "" method= "POST" > Name: <input type= "text" name= "username" id= "username"/> Age: <select name= "aged" > <option value= ">16" > Less than 16</option> <option value= "16-30" selected>16-30</option> <option value= "31-50" >31-50</option> <option value= "51-80" >51-80</option> </select></td> <input type= "Submit" Name= "Btn_submit" value= "submitted"/>
|
The implementation interface is shown in Figure 5-5.
This chapter describes what wildcard characters are, how to use wildcards, and how to use the LIKE operator for a wildcard search to make complex filtering of data.
8.1 Like operator
All of the operators described earlier are filtered for known values. Whether it matches one or more values, the test is greater than or less than a known value, or it checks a range of values, in common that the values used in the filter are known. However, this filtering method is not always easy to use. For example, how do you search for all products in the product name that contain text anvil? Certainly not with a simple comparison operator, you must use a wildcard character. Wildcard characters are used to create a search pattern that compares specific data. In this example, if you want to find all the products with the name anvil, you can construct a wildcard search pattern to find the products that appear anvil anywhere in the product name.
A special character used by wildcards (wildcard) to match a part of a value.
Search pattern is a search condition that consists of a literal, wildcard, or combination of both.
The wildcard character itself is actually a special meaning in the WHERE clause of SQL, and SQL supports several wildcard characters.
To use wildcard characters in search clauses, you must use the LIKE operator. Like instructs MySQL, followed by a search pattern that uses wildcard matching rather than direct equality matching to compare.
When is the predicate operator not an operator? The answer is when it acts as a predicate (predi-cate). Technically, like is a predicate rather than a operator. Although the end result is the same, you should have an understanding of the term so that it is not known when you encounter this term in an SQL document.
8.1.100 semicolon (%) wildcard characters
The most commonly used wildcard character is the percent sign (%). In a search string,% indicates that any character appears any number of times. For example, to find all the products that start with the word jet, you can use the following SELECT statement:
This example uses the search mode ' jet% '. When this clause is executed, any word that starts with Jet is retrieved. % tells MySQL to accept any character after jet, no matter how many characters it has.
Case sensitivity depending on how MySQL is configured, the search can be case-sensitive. If case sensitive, ' jet% ' and jetpack 1000 will not match.
Wildcard characters can be used anywhere in search mode and can use multiple wildcard characters. The following example uses two wildcard characters, which are at both ends of the pattern:
The search mode '%anvil% ' represents a value that matches any position containing text anvil, regardless of what characters appear before or after it.
Wildcards can also appear in the middle of search mode, although this is not very useful. The following example finds all the products with s beginning with E:
It is important to note that% can match 0 characters in addition to one or more characters. % represents 0, one, or more characters at a given position in the search pattern.
Note that trailing space trailing spaces may interfere with wildcard matching. For example, if you save a word anvil, if it has one or more spaces after it, the clause where prod_name like '%anvil ' will not match them, because there are extra characters after the last L. An easy way to solve this problem is to append a% to the search pattern. A better approach is to use the function (the 11th chapter will introduce) to remove the trailing spaces.
Note null Although it seems that the% wildcard can match anything, there is an exception, that is, null. Even where prod_name like '% ' cannot match a row with a value of NULL as the product name.