2014-02-19 155 views
0
<?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> 

我在mysql_fetch_assoc($agent_res)中使用了$agent_res兩次。 它在第一個while循環中正常工作,我從數據庫中獲取值。 但是當我在while循環中第二次使用它時,它不會進入while循環。 第二次while循環之前,我打印的值爲$agent_res,我得到資源ID。 它打印如下:Resource id #6 請任何人都可以幫助我解決這個問題。 在此先感謝。 等待您的答覆。爲什麼在以下情況下資源ID無法訪問?

回答

2

你需要設置指針回到開始的規定在這裏: reset pointer

mysql_data_seek($agent_res, 0); 
while($row2 = mysql_fetch_assoc($agent_res)) 
.... 
    ... 
+0

謝謝。它的工作... –

相關問題