My own PHP knowledge. I have never learned PHP before. I recently used PHP for a project. I decided to add the following constraints to the SQL statement: left (text, 20) I only use the first 20 words of text. I have never learned PHP before. I recently used PHP for a project.
1. you can add restrictions in SQL statements: left (text, 20) only takes the first 20 words of text;
2. limit fromRecord and RecordNum can be used as pages. for example, limit indicates that 30 records are traversed from the first record;
3. join two tables: table1 join table2 using x (x is the public field of the two tables), or table1 join table2 on table1.x = table2.x
4. php can use $ page =$ _ GET ['Page'] to obtain querystring.
Or
$ Page = $ _ REQUEST ['Page'];
The Request can contain post, get, QueryString, and other characters;
Before that, I saw a stupid method:
Parse_str ($ _ SERVER ['query _ string'], $ output); // first save the query string to an array $ output
$ Page = $ output ['Page']; // index the data based on the variable name.
5. Comparison of date functions in php is actually a string comparison;
6. data of the date type in mysql can be: 2000-02-03, 2002.02.03, 2002.2.3, 02.02.03, 02.2.3, that is, there must be a month and a day, and it must be separated by '-' or.
7 data () to obtain the time will have a time zone problem, I found that the time is eight hours less, because the default configuration in php. ini is GTM United States time zone;
Solution: modify php. ini:
[Date]
; Defines the default timezone used by the date functions
Date. timezone = "Asia/Shanghai"
Or add date_Default_TimeZone_set ("PRC") to the date () function ");
For a period of time, when debugging, I always say that I lack ")" at the body, and it takes a long time for intval ($ _ POST ['sumetype, in the database, this field is varchar (50). I didn't use the intval function in the zengsong table because its ID is 1, 2... integer and char type can be converted to each other, but in the other two tables is A5A, SP07-01 and so on, but how to convert it to int type?
Let's take a look at the declaration of the intval function:
The intval function is used to obtain the integer of a variable: int intval (mixed var [, int base]).
Return the integer value of the variable var by using a specific hexadecimal conversion (decimal by default.
Var can be any scalar type. Intval () cannot be used for array or object.
9. for another inexplicable problem, you can log on with username 1 and change 'Bo' to log on.Error: The running time is incorrect: ")", nnd is missing. Check that the variable type in the SQL statement is inconsistent with that in the database,
10 when the number is converted from a floating point number to an integer in php, the number is rounded up (dropping decimal places ).
11 in the mysql insert statement, assume that the auto-increment field should be replaced by (NULL.
12 php Chinese garbled characters ??? Solution:
Add mysql_query ("set names 'gb2312'") after mysql_connect '");
Or you can use utf8 encoding.
Also, the iconv ("GBK", "UTF8", "string") function can convert various character codes.
Limit. 1 in SQL statements, you can add constraints: left (text, 20) only takes the first 20 words of text ;...