/* Export xls user personal information */ Function export (){ Header ("Content-type: application/octet-stream "); Header ("Accept-Ranges: bytes "); Header ("Content-type: application/vnd. ms-excel "); Header ("Content-Disposition: attachment; filename = user information table". date ("Y-m-d"). ". xls "); Header ("Pragma: no-cache "); Header ("Expires: 0 "); // Start exporting xls $ Tag0 = iconv ("UTF-8", "GB2312", 'user ID '); $ Tag1 = iconv ("UTF-8", "GB2312", 'Username '); $ Tag2 = iconv ("UTF-8", "GB2312", 'Waiting for collect '); $ Tag3 = iconv ("UTF-8", "GB2312", 'Total bonuses '); $ Tag4 = iconv ("UTF-8", "GB2312", 'account login '); $ Tag5 = iconv ("UTF-8", "GB2312", 'account city '); $ Tag6 = iconv ("UTF-8", "GB2312", 'account opening address '); $ Tag7 = iconv ("UTF-8", "GB2312", 'bank card number '); $ Tag8 = iconv ("UTF-8", "GB2312", 'cardholder name '); Echo "$ tag0 \ t $ tag1 \ t $ tag2 \ t $ tag3 \ t $ tag4 \ t $ tag5 \ t $ tag6 \ t $ tag7 \ n "; //// Query a table // $ Arr = M ('textpage')-> field ('username, count (id) as allcount, sum (price) as allprice ') -> group ('Username')-> select (); $ Field = "crowd_textpage.tid, crowd_textpage.username, users. bankName, users. city, users. bankAddress, Users. bankCard, users. bankUsr, count (crowd_textpage.id) as allcount, sum (crowd_textpage.price) as allprice "; $ Arr = M ('textpage')-> field ($ field) -> Join ('crowd _ user as users ON crowd_textpage.username = users. Username ') -> Group ('crowd _ textpage. Username ') -> Select (); // Dump (M ('textpage')-> getLastSql (); die; Foreach ($ arr as $ key => $ val ){ // $ Date = date ('Y-m-D', $ val ['pay _ time']); $ Tid = iconv ("UTF-8", "GB2312", $ val ['tid']); $ Tid = $ tid? $ Tid :'-'; $ Username = iconv ("UTF-8", "GB2312", $ val ['username']); $ Username = $ username? $ Username :'-'; $ Allcount = iconv ("UTF-8", "GB2312", $ val ['allcount']); $ Allcount = $ allcount? $ Allcount :'-'; $ Allprice = iconv ("UTF-8", "GB2312", $ val ['allprice']); $ Allprice = $ allprice? $ Allprice :'-'; $ BankName = iconv ("UTF-8", "GB2312", $ val ['bankname']); $ BankName = $ bankName? $ BankName :'-'; $ City = iconv ("UTF-8", "GB2312", $ val ['city']); $ City = $ city? $ City :'-'; $ BankAddress = iconv ("UTF-8", "GB2312", $ val ['bankaddress']); $ BankAddress = $ bankAddress? $ BankAddress :'-'; $ BankCard = iconv ("UTF-8", "GB2312", $ val ['bankcard ']); $ BankCard = $ bankCard? $ BankCard :'-'; $ BankUsr = iconv ("UTF-8", "GB2312", $ val ['bankusr']); $ BankUsr = $ bankUsr? $ BankUsr :'-'; Echo "$ tid \ t $ username \ t $ allcount \ t $ allprice \ t $ bankName \ t $ city \ T $ bankAddress \ t' $ bankCard \ t $ bankUsr \ n "; } } |