When php uses the header to export an excel file, the first line is missing.
http://192.168.0.200/test/khall.php?mindate=2014-04-01&maxdate=2014-04-30&keys=
= '". $ Mindate."' and dates <= '". $ maxdate."' "; if (! Empty ($ _ GET ['Keys ']) {$ keys = $ _ GET ['Keys']; $ ww = "('region' like '% ". $ keys. "% 'or 'type' like' % ". $ keys. "% 'or 'names' like' % ". $ keys. "% 'or 'add' like' % ". $ keys. "% 'or 'dur' like' % ". $ keys. "% ')"; $ wh = "where {$ ww} and {$ dates}";} else {$ wh = "where {$ dates }";} $ SQL = "SELECT * FROM 'khxx' {$ wh}"; // echo "$ SQL"; mysql_query ('set names gbk '); $ query = mysql_query ($ SQL); $ rs = mysql_fetch_array ($ query); while ($ Rs = mysql_fetch_array ($ query )) {echo "{$ rs ['dates']} \ t {$ rs ['type']} \ t {$ rs ['region']} \ t {$ rs ['names']} \ t {$ rs ['add']} \ t {$ rs ['phone']} \ t {$ rs ['no']} \ t {$ rs ['set']} \ t {$ rs ['dur']} \ t {$ rs ['give']} \ t {$ rs ['moneys' ]} \ t {$ rs ['attn']} \ t {$ rs ['username']} \ t {$ rs ['REM ']} \ n ";} ?>
It is normal to input SQL statements using echo.
SELECT * FROM `khxx` where dates>='2014-04-01' and dates<='2014-04-30'
The first data entry is missing when it is generated.
Reply to discussion (solution)
Also, mysql_query ('set names gbk') is used ');
However, the $ key variable value will be passed on the previous page because the passed value is UTF-8 and will become invalid when the SQL statement is executed.
$ Rs = mysql_fetch_array ($ query); // you read one more row here.
While ($ rs = mysql_fetch_array ($ query )){
$ Keys = $ _ GET ['Keys '];
Change
$ Keys = iconv ('utf-8', 'gbk', $ _ GET ['Keys ']);
Also, mysql_query ('set names gbk') is used ');
However, the $ key variable value will be passed on the previous page because the passed value is UTF-8 and will become invalid when the SQL statement is executed.
% ". $ Keys." % changed to % ". iconv ('utf-8', 'gbk', '$ keys')." %
$ Keys = $ _ GET ['Keys '];
Change
$ Keys = iconv ('utf-8', 'gbk', $ _ GET ['Keys ']);
What can I do if I miss your mention today?
Just get to know the rule.