<p> There is a period of time did not update the blog, for fear of being Baidu forgotten Ah, biu~biu~. Recently there is a project to count the URL and title of the site, save in Excel, the following is the specific code </p>
<pre class= "php" name= "code" ><!--p
PHP generates Excel reports by sending header () header information
Header ("Content-type:application/vnd.ms-execl");
Header ("Content-type:application/vnd.ms-excel; charset=gb2312 ");
Tell the browser the name of the file and ask the client to download
Header ("Content-disposition:filename=test.xls");
Header ("Pragma:no-cache");
Header ("expires:0");
$link = mysql_connect (' localhost ', ' root ', ') or die (' could not connect: '. Mysql_error ());
mysql_select_db (' Novartis ') or die (' could not select database ');
mysql_query ("SET NAMES gb2312");
$query = ' SELECT title,keywords,url,description from Cms_content ';
$result = mysql_query ($query) or Die (' Query failed: '. mysql_error ());
Display results in HTML
$str =mb_convert_encoding ("Test 1", "gb2312", "utf-8");
echo "Titlet";
echo "KEYWORDST";
echo "Descriptiont";
echo "Urltn";
/* Format: NewLine: "tn": Between Cells: "T" * *
while ($line = Mysql_fetch_array ($result, Mysql_assoc)) {
echo $line [' title ']. T ";
echo $line [' keywords ']. T ";
echo $line [' description ']. T ";
echo $line [' url ']. TN ";
}
Releasing the result set
Mysql_free_result ($result);
Close connection
Mysql_close ($link);
-->
</pre>
<div> </div>