04-10-2009, 08:00 AM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Mar 2009
Posts: 5
Thanks: 0
|
PHP MySQL Table not loading sometimes
Hi all,
I have been facing this problem from quite sometime. I have to fetch data from a mysql db and display it as a table. This is my code
PHP Code:
$con=mysql_connect($hostName,$user,$password);
if(!$con)
{
echo "connection failed";
}
mysql_select_db($dbName,$con);
$sql="select * from market_details";
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Market Code</th>
<th>Market Name</th>
</tr>
</thead>
<tbody>
<?php
while($row=mysql_fetch_array($result,$con))
{
?>
<tr class="gradeA">
<td class="center" ><?php echo $row['market_code']; ?></td>
<td class="center" ><?php echo $row['market_name']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
The problem is, sometimes the table contents appear blank. It shows data when i refresh the page.
I suspect the problem is in mysql_fetch_array($result,$con), maybe it is not fetching the data sometimes , thus it is not showing it.
Where have I gone wrong ?
|
|
|
|