Second while loop not running. Why?

后端 未结 6 1854
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 11:37

I have two while loops running one after the other (not inside of each other) - I\'ve simplified the code a bit so that only the important parts of it are listed below. The

6条回答
  •  不知归路
    2021-01-15 11:42

    The MySQL extension keeps track of an internal row pointer for each result. It increments this pointer after each call to mysql_fetch_assoc(), and is what allows you to use a while loop without specifying when to stop. If you intend on looping through a result set more than once, you need to reset this internal row pointer back to 0.

    To do this, you would mysql_data_seek() after the first loop:

    while ($row = mysql_fetch_assoc($result_work_id)) {
        $query_work_title .= "OR '$work_id' ";
    }
    mysql_data_seek($result_work_id, 0);
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题