从PHP修改多行mySQL数据

从PHP修改多行mySQL数据,php,mysql,Php,Mysql,我有一些php脚本,我想在mySQL表中的每一行上运行。php脚本: function replacespaces($text) { return preg_replace_callback('/[\<]pre(.*)[\>](.*)[\<]\/pre[\>]/i', create_function( '$matches', 'return "<pre".$matches[1].">".

我有一些php脚本,我想在mySQL表中的每一行上运行。php脚本:

function replacespaces($text) {
    return preg_replace_callback('/[\<]pre(.*)[\>](.*)[\<]\/pre[\>]/i', 
        create_function(
            '$matches',
            'return "<pre".$matches[1].">".str_replace(" ", " ", $matches[2])."</pre>\n";'
        ), $text);
}
函数替换空格($text){
返回preg\u replace\u回调('/[\](.*)[\]/i',
创建函数(
“$matches”,
“return”“.str\u replace(“,”,$matches[2])。“\n””
)美元文本);
}
我需要遍历表“jos_picmicro_content”中的mySQL数据库,将字段“fulltext”的内容传递给上述函数,并将结果插入到字段“fulltext”中。听起来很容易做到,虽然我在这方面没有经验!这张桌子大约有500行长

$result = mysql_query("SELECT * FROM jos_posmicro_content");
while ($row = mysql_fetch_array($result)) {
    $text = replacespaces($row['fulltext']);
    $sql = "UPDATE jos_posmicro_content SET fulltext = '" . mysql_real_escape_string($text) . "' WHERE ????";
    mysql_query($sql);
}

你只是想改变一下吗????识别要更新的行的部分(例如,其中id=$row['id']或主键是什么)。

该代码就是一个示例吗?因为它用空格代替了空格。谢谢你,丹。我不熟悉mysql方面的事情。您所说的“主键”是什么意思?您如何从表中选择正确的行来存储数据?你怎么区分一排和另一排?我不知道你是如何在不知道主键是什么的情况下编写查询来创建这个表的……同样,我在等待你的响应时用谷歌搜索了一下。再次感谢你,丹。