dongpai1942 2012-07-31 11:01
浏览 46
已采纳

什么改变循环中的条件:while(mysql_fetch_array($ var))?

I'm a beginner C programmer. I recently started learning PHP and MySQL and encountered this interesting behavior with while loop:

while ($pages = mysql_fetch_array($pages_set))
    {statement}

I previously learned that condition must be changed somewhere in the loop (or in the expression itself) in order for the loop to be finite, but in this case i just can't see it.

I researched a bit about mysql_fetch_array() function and found this:

Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.

Is it true to say that the pointer moves through the row and when it reaches the end it will return 0 or NULL?

  • 写回答

1条回答 默认 最新

  • dongruolin5324 2012-07-31 11:13
    关注

    The pointer moves to the next row in the recordset with each iteration, so that when there is no data left then $pages will be NULL and the loop will end.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗