<?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> </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>
我在$agent_res
中使用了mysql_fetch_assoc($agent_res)
两次。
它在第一个while循环中正常工作,我从数据库中获取值。
但是当我在while循环中第二次使用它时,它不会进入while循环。
在第二次循环之前,我打印了$agent_res
的值,我得到了资源ID。
它打印如下:Resource id #6
请任何人帮我解决这个问题。
提前致谢。
等待你的回复。
答案 0 :(得分:2)
您需要将指针设置回如此处所述的开头: reset pointer
mysql_data_seek($agent_res, 0);
while($row2 = mysql_fetch_assoc($agent_res))
....
...