时间:2021-07-01 10:21:17 帮助过:21人阅读
require dirname(__FILE__) . '/../connection.php';
mysql_select_db("news",$connextion);
mysql_query("SET NAMES utf8");
$query = mysql_query("SELECT * FROM temp_t where mykey = '1'");
while($rows = mysql_fetch_array($query)){
mysql_query("UPDATE temp_t SET mykey='2' WHERE id='".mysql_real_escape_string($rows['id'])."'");
mysql_query("INSERT INTO table1 (id,title,content,date) values ('".mysql_real_escape_string($rows['id'])."','".mysql_real_escape_string($rows['title'])."','".mysql_real_escape_string($rows['content'])."','".mysql_real_escape_string($rows['date'])."'");
}
mysql_close($connextion);
require dirname(__FILE__) . '/../connection.php';
mysql_select_db("news",$connextion);
mysql_query("SET NAMES utf8");
$query = mysql_query("SELECT * FROM temp_t where mykey = '1'");
$jon = array();
while($rows = mysql_fetch_array($query)){
$jon['a'] = $rows['id'];
$jon['b'] = $rows['title'];
$jon['c'] = $rows['content'];
$jon['d'] = $rows['date'];
$pjon .= json_encode($jon).',';
}
mysql_close($connextion);
$njso = json_decode('['.substr($pjon,0,-1).']');
foreach($njso as $nx){
if($nx->a){
require dirname(__FILE__) . '/../connection.php';
mysql_select_db("news",$connextion);
mysql_query("SET NAMES utf8");
mysql_query("UPDATE temp_t SET mykey='2' WHERE id='".mysql_real_escape_string($nx->a)."'");
mysql_query("INSERT INTO table1 (id,title,content,date) values ('".mysql_real_escape_string($nx->a)."','".mysql_real_escape_string($nx->b)."','".mysql_real_escape_string($nx->c)."','".mysql_real_escape_string($nx->d)."'");
mysql_close($connextion);
}
}