1 In SQL statements, you can add restrictions: left(text, 20) to only take the first 20 words of the text text;
2 You can use limit fromRecord and RecordNum as a pagination, for example, limit 0,30 means traversing 30 records from the first record;
3 The joining of two tables can be: table1 join table2 using x (x is the common field of the two tables), or table1 join table2 on =
4 php to get querystring can be used with $page = $_GET['page'];
or
$page = $_REQUEST['page'];
Among them, Request can obtain post, get, QueryString and other characters;
Before that I saw a stupider method:
parse_str($_SERVER['QUERY_STRING'],$output); // First save the query string in an array $output
$page = $output['page']; //Then index according to the variable name
5 The comparison of date functions in php is actually a comparison of strings;
6 The 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 get time will have time zone problems. I found that the time is 8 hours less because the default configuration inside is GTM US time zone;
Solution: Can be modified:
[Date]
; Defines the default timezone used by the date functions
= "Asia/Shanghai"
Or when using the date() function, add date_Default_TimeZone_set("PRC");
8 For a while, when debugging, I always said that I was missing ")" at the body. It took a long time to have an issue with intval($_POST['consumeType']). In the database, this field is varchar(50). In the zengsong table, I did not use the intval function because its ID is 1, 2... Integers and char types can be converted to each other, but in the other two tables, they are A5A, SP07-01, etc., but how does it convert to int type?
Let's take a look at the declaration of the intval function:
Intval function is used to obtain the integer value of a variable: int intval ( mixed var [, int base] )
Returns the integer value of the variable var by using a specific binary conversion (default is decimal).
var can be any scalar type. intval() cannot be used for array or object.
9 Another inexplicable problem, just log in with username 1. If you change to 'bo', the system will have an error: I said my running time is wrong: ")", nnd. After checking, it turned out that the variable types in the SQL statement were inconsistent with those in the database.
10 php when converting from a floating point number to an integer, the number will be rounded (decimal places are discarded).
11 In mysql insertion statement, if it is a self-incremented field, use (NULL) instead.
12 php Chinese garbled code??? Problem solution:
Add mysql_query("set names 'gb2312'");
Or use utf8 to encode it all, so there is no need to add the above statements.
There is also the function iconv("GBK", "UTF8", "String"); which can realize the conversion of various character encodings.
2 You can use limit fromRecord and RecordNum as a pagination, for example, limit 0,30 means traversing 30 records from the first record;
3 The joining of two tables can be: table1 join table2 using x (x is the common field of the two tables), or table1 join table2 on =
4 php to get querystring can be used with $page = $_GET['page'];
or
$page = $_REQUEST['page'];
Among them, Request can obtain post, get, QueryString and other characters;
Before that I saw a stupider method:
parse_str($_SERVER['QUERY_STRING'],$output); // First save the query string in an array $output
$page = $output['page']; //Then index according to the variable name
5 The comparison of date functions in php is actually a comparison of strings;
6 The 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 get time will have time zone problems. I found that the time is 8 hours less because the default configuration inside is GTM US time zone;
Solution: Can be modified:
[Date]
; Defines the default timezone used by the date functions
= "Asia/Shanghai"
Or when using the date() function, add date_Default_TimeZone_set("PRC");
8 For a while, when debugging, I always said that I was missing ")" at the body. It took a long time to have an issue with intval($_POST['consumeType']). In the database, this field is varchar(50). In the zengsong table, I did not use the intval function because its ID is 1, 2... Integers and char types can be converted to each other, but in the other two tables, they are A5A, SP07-01, etc., but how does it convert to int type?
Let's take a look at the declaration of the intval function:
Intval function is used to obtain the integer value of a variable: int intval ( mixed var [, int base] )
Returns the integer value of the variable var by using a specific binary conversion (default is decimal).
var can be any scalar type. intval() cannot be used for array or object.
9 Another inexplicable problem, just log in with username 1. If you change to 'bo', the system will have an error: I said my running time is wrong: ")", nnd. After checking, it turned out that the variable types in the SQL statement were inconsistent with those in the database.
10 php when converting from a floating point number to an integer, the number will be rounded (decimal places are discarded).
11 In mysql insertion statement, if it is a self-incremented field, use (NULL) instead.
12 php Chinese garbled code??? Problem solution:
Add mysql_query("set names 'gb2312'");
Or use utf8 to encode it all, so there is no need to add the above statements.
There is also the function iconv("GBK", "UTF8", "String"); which can realize the conversion of various character encodings.