dongyan7988 2014-02-19 05:43
浏览 6
已采纳

为什么在以下情况下无法访问资源ID。

<?php 

    $agent_details = "SELECT * FROM `database`.`table` WHERE country = 'India'";

    $agent_res = $n -> querySend($agent_details);

    ?>
<table border="1" cellspacing="1" cellpadding="1" id="outerTable">
    <thead valign="top">
        <tr>
          <td>S.No.</td>
          <td>Agent </br>name</br>&nbsp;</td>
          <td>Port / Offices</td>
          <td>Address</td>
          <td>Tel</td>
          <td>Fax</td>
          <td>Contact</td>
          <td>Email Address</td>
          <td>Website Address</td>
        </tr>
    <?php
        while($row1 = mysql_fetch_assoc($agent_res))
        {   
        ?>
            <tr>
                <td><?php echo $row1['agent_no'] ?></td>
                <td><?php echo $row1['agent_name'] ?></td>
                <td><?php echo $row1['port'] ?></td>
                <td><?php echo $row1['address'] ?></td>
                <td><?php echo $row1['tel'] ?></td>
                <td><?php echo $row1['fax'] ?></td>
                <td><?php echo $row1['contact'] ?></td>
                <td><?php echo $row1['email_id'] ?></td>
                <td><?php echo $row1['website_address'] ?></td>
            </tr>
         <?php
        }
    ?>   
    </thead>
    <tbody valign="top">
        <tr>
            <td class="cell">Strength Ocean Air BB</td>
            <td class="cell">Communication / Response Time</td>
            <td class="cell">Rate Competitiveness</td>
            <td class="cell">Expertise in Execution</td>
            <td class="cell">Nominations</td>
            <td class="cell">Financial Dealing</td>
            <td class="cell">Country Network</td>
            <td class="cell">Network Assoc.</td>
            <td class="cell">Agency Agreement</td>
            <td class="cell">Average Score</td>
            <td class="cell">Origin Charges</td>
            <td class="cell">Destn Charges</td>
        </tr>
   <?php   

       while($row2 = mysql_fetch_assoc($agent_res))
       {    
        ?>  
        <tr>
            <td class="cell"><?php echo $row2['strength_ocean_air_bb'] ?></td>
            <td class="cell"><?php echo $row2['communication_or_responce_time'] ?></td>
            <td class="cell"><?php echo $row2['rate_competitiveness'] ?></td>
            <td class="cell"><?php echo $row2['expertise_in_execution'] ?></td>
            <td class="cell"><?php echo $row2['nominations'] ?></td>
            <td class="cell"><?php echo $row2['financial_dealing'] ?></td>
            <td class="cell"><?php echo $row2['country_network'] ?></td>
            <td class="cell"><?php echo $row2['network_assoc'] ?></td>
            <td class="cell"><?php echo $row2['agency_agreement'] ?></td>
            <td class="cell"><?php echo $row2['avg_score'] ?></td>
            <td class="cell"><?php echo $row2['origin_charges'] ?></td>
            <td class="cell"><?php echo $row2['destination_charges'] ?></td>
        </tr>     
         <?php
        }
    ?>
    </tbody>
</table>

I have used $agent_res two times in mysql_fetch_assoc($agent_res). It is working properly in first while loop and I am getting values from database. But when I used it in second time in while loop, it is not going inside the while loop. Before second while loop, I printed value of $agent_res, I am getting the resource ID. It printed like this: Resource id #6 Please can anyone help me to resolve this issue. Thanks in advance. waiting for your replies.

  • 写回答

1条回答 默认 最新

  • douxing2652 2014-02-19 05:45
    关注

    you need to set the pointer back to the beginning as stated here: reset pointer

     mysql_data_seek($agent_res, 0);
     while($row2 = mysql_fetch_assoc($agent_res))
     ....
      ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。