如何使用mysql的ref数据循环php?

时间:2015-07-06 08:44:44

标签: php mysql loops

如何使用mysql的ref数据循环php?

工作流程:

Loop If column 'xxx' == ''
{

$sql = "SELECT * FROM table WHERE xxx == '' order by id desc";
$result = mysql_query($sql);
$datas=mysql_fetch_array($result);{
$id = stripslashes(str_replace('\r\n', '<br>',($datas['id'])));
}

$sql = "UPDATE table SET xxx = 'test' WHERE id = '$id' ";
$dbQuery = mysql_query($sql);'
}

1 个答案:

答案 0 :(得分:1)

ypur查询令人困惑。你为什么要用它们存储带有html的id?无论如何,这应该工作

$sql = "SELECT * FROM table WHERE xxx != '' "; //ORDER BY will not work since ids are not int
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result){

    $id = stripslashes(str_replace('\r\n', '<br>',($row['id'])));

    $sql = "UPDATE table SET xxx = 'test' WHERE id = '$id' ";
    $dbQuery = mysql_query($sql);'
}