PHP Export non-garbled non-random sequence of wonderful problems ask the big God to help my brother

Source: Internet
Author: User
The first diagram above is the export, the second is the actual data of the database, the careful buddies found that the exported figure three all changed to 0, this god horse situation AH

Ask the great God for guidance
The code is as follows:
!--? phpdefine (' Norobot ', true);d efine (' Curscript ', ' charge '); Require_once '. Include/common.inc.php '; Header ("Content-type:application/vnd.ms-excel;charset=utf-8"); Header (" Content-disposition:attachment;filename= prepaid card. xls "); $page = $page?: 1; $results = Array ();   $condition = "; echo "Prepaid phone number". "   \ t "; echo "Prepaid card serial number". "   \ t "; echo "Recharge amount". "  \ t "; echo "Real charge amount". " \ t "; echo "Recharge time". " \ t "; $query = $mysqli--->multi_query (' Call Up_user_getcardinfo (" '. $condition. ' "," '. $page. ' "," 900000 ") ') or Die ($ Mysqli->error); $query = $mysqli->store_result (); while ($record = Mysqli_fetch_array ($query, Mysqli_both)) {$phone = $record [' phone ']; $cardid = $record [' Cardid '];$ charge = $record [' Charge ']; $achieve = $record [' achieve ']; $chgdate = $record [' usedate ']; echo "\ n"; echo $phone. " \ t "; Echo $cardid." \ t "; echo $charge. " \ t "; echo $achieve. " \ t "; echo $chgdate. " \ t ";   }if (Is_object ($query)) $query->free_result (); $mysqli->next_result (); 


Reply to discussion (solution)

No one!

Another method is the same effect, the code is as follows:

 
 $val) {$title [] = $key; $field [] = $val;} # $query = $mysqli->query ("Select Uid,username,phone from Ccna_members limit") or Die ($mysqli->error); # $query = $ Mysqli->multi_query ("SELECT * from Ccna_members limit") or Die ($mysqli->error); $query = $mysqli->multi_ Query ($_session["Exp_sql"]) or Die ($mysqli->error), $query = $mysqli->store_result ();//$csv _data = Array (Array ( ' uid ', ' username ');//All records are saved. $csv_data = Array (array ());//press in the header, place the field on the first row for ($i =0; $i < count ($field); $i + +) {$csv _d ata[0][$i]= $field [$i];} while ($row = Mysqli_fetch_array ($query, Mysqli_both)) {//array_push ($csv _data, Array ($row [0], $row [' username '])); Row_array = Array (), for ($i =0, $i < count ($title), $i + +) {#array_push ($row _array,iconv ("Utf-8", "gb2312", $row [$title [$i]]); Array_push ($row _array, $row [$title [$i]];} Array_push ($csv _data, $row _array);} Exporttocsv ($csv _data,$_session["Exp_filename"]. ". CSV ");? >

echo $cardid. " \ t ";
Switch
echo "' $cardid \ T";

echo $cardid. " \ t ";
Switch
echo "' $cardid \ T";


It's still the same, No. Thank you for your answer.

How can you produce a text file, but the suffix is different


Do you mind if I add your buckle?

How can you produce a text file, but the suffix is different



Can I change into echo "$cardid \ T"; Still can't, don't know why.

"' $cardid \ T";
There is a single quotation mark
is also thinking: the word is too small may not see clearly

"' $cardid \ T";
There is a single quotation mark
is also thinking: the word is too small may not see clearly



Thank you. Knot stickers to points

You can do it as a string.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.