PHP+MySQL取出数据库内容,经正则表达式处理后更新至另一张表

来源:互联网 发布:八宝茶的软件 编辑:程序博客网 时间:2024/05/01 12:56
<?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);?>

0 0