【问题标题】:How to loop php using ref data from mysql?如何使用来自 mysql 的 ref 数据循环 php?
【发布时间】:2015-09-23 08:00:42
【问题描述】:

如何使用 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);'
}

【问题讨论】:

  • 这里的xxx是什么变量
  • 那么如果你没有它的价值,你将如何检查它是否不为空
  • 那么,目前,您的表 ID 不是整数?他们有斜线吗?为什么?

标签: php mysql loops


【解决方案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);'
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-15
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 2015-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多