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>

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.

Anand Jaju
  • 458
  • 3
  • 12
  • 28

1 Answers1

2

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))
 ....
  ...
Community
  • 1
  • 1
bart2puck
  • 2,432
  • 3
  • 27
  • 53