【问题标题】:While fetching table fetching the same table again php, how is it possible?在获取表时再次获取同一个表 php,这怎么可能?
【发布时间】:2019-06-28 20:14:31
【问题描述】:
$result=("select * FROM blablabla ") ;
while($row = mysql_fetch_array($result))

{$another=("select * FROM blablabla ") ;
 while($dow = mysql_fetch_array($another)){} }

这不起作用,请给我提示

【问题讨论】:

    标签: php mysql


    【解决方案1】:

    您实际上并没有运行您的查询:

    $result=mysql_query("select * FROM blablabla ") ;
    while($row = mysql_fetch_array($result))
    {
      // do stuff
    }
    

    Please, don't use mysql_* functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解 prepared statements,并使用 PDOMySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial

    【讨论】:

    • 不,我感兴趣的是当我获取一张表时是否有任何错误,同时连接并获取同一张表
    【解决方案2】:

    也许你的意思是,

    $result = mysql_query("select * FROM blablabla ") ;
    while($row = mysql_fetch_array($result))
    {
    
    }
    

    【讨论】:

    • 这就是我的意思,blablabla 是同一张表 $result=("select * FROM blablabla") ; while($row = mysql_fetch_array($result)) {$another=("select * FROM blablabla") ; while($dow = mysql_fetch_array($another)){} }
    【解决方案3】:

    你的 while 循环应该可以工作,你可能在其他地方有一些错误。

    看看 this post 里面有 3 个 while 循环

    我的提示是尝试调试您的代码并查看它在哪里不起作用,第二个提示是尝试移动到 PDO 或 MYSQLI

    【讨论】:

      猜你喜欢
      • 2015-04-24
      • 1970-01-01
      • 2022-09-25
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多