dongluzhi5208 2014-02-08 14:29
浏览 55
已采纳

while while循环中有两个不同的函数?

I have two mysql_queries who have two while loops in fetch_assoc. One written inside another. I want to take one while loop inside a function and another inside another function. How to do that? Help. Here's an example of what I'm trying to say.

$query1 = mysql_query('...');
while($row1 = mysql_fetch_assoc($query1)){
$id = $row1['id'];

$query2 = mysql_query('...');
while($row2 = mysql_fetch_assoc($query2)){ 
$picture = $row2['picture'];

echo $id.' '.$picture;

} }

I want to take these two inside two different functions..

function query1(){
1st query with 1st while loop
}

function query2(){

2nd query with 2nd while loop
}

So that I can execute them just the way it is supposed to be..

query1();
query2();

echo $id.' '.$picture;

How to achieve this? Help.

  • 写回答

1条回答 默认 最新

  • dongyong6332 2014-02-08 14:35
    关注

    You could structure it as follows:

    function query2(){
        //do inner stuff
    }
    function query1(){
        //do stuff
        query2();
    }
    query1();
    

    Let me know if you need more context!

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度