The contents of the database tutorial to save the file in an array Here to save the commonly used content in the database to a standard php format file, it is also more convenient to use, the following code.
* /
$ res = mysql tutorial _query ("select k1, k2 from" .table ('keywords'). "");
$ str = "<? php rn";
while ($ rs = mysql_fetch_array ($ res))
{
$ rss [0]. "'] ='". $ rs [1]. "'; rn";
}
$ str. = "?>";
file_put_contents ("keyword.php", $ str);
echo "export success";
//Method Two
$ f = file_get_contents ("w1.txt");
$ f = str_replace ("rn", "<br>", $ f); // Replace line breaks
$ arr = explode ("<br>", $ f);
$ str = "<? php rn";
foreach ($ arr as $ t)
{
$ rs = explode ("|", $ t);
// can not contain? Other special symbols
$ str. = "$ keyword ['". str_replace ("?", "", $ rs [0]).' ']' '' '. str_replace ("?", "", $ rs [1]). "'; rn";
}
$ str. = "?>";
file_put_contents ("keyword.php", $ str);
echo "export success";
//conn.php file
$ conn = mysql_connect ($ mysql_host, $ mysql_user, $ mysql_password) or die ('Connection Server Error');
mysql_select_db ($ mysql_db) or die ("Select database error");
mysql_query ("set names 'gbk'");
function table ($ t)
{
global $ mysql_table_prefix;
return $ mysql_table_prefix. $ t;
}
?>