<?php
$mysql = mysql_connect("localhost","root","password");
mysql_select_db("dbname", $mysql);
$query = "SELECT id,content FROM table1";
$result = mysql_query($query, $mysql);
$st = array();
while($row = mysql_fetch_row($result)){
$st['id'] = $row[0];
$st['content'] = mb_substr(strstr(preg_replace('/<[^>]*>/','',$row[1]),'查找字符串'),0,48,'utf-8').'...';
$query2 = "UPDATE table2 Set description ='".$st['content']."' WHERE id =".$st['id'];
$result2 = mysql_query($query2, $mysql);
}
mysql_free_result($result);
mysql_free_result($result2);
mysql_close($mysql);
print_r($st);
?>
PHP+MySQL取出数据库内容,经正则表达式处理后更新至另一张表
最新推荐文章于 2021-11-07 01:21:13 发布