TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-10-2009, 08:00 AM   #1 (permalink)
The Wanderer
 
amitdgr's Avatar
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
amitdgr is on a distinguished road
Default 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 ?
amitdgr is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on PHP MYSQL Forms Input deesudesu Absolute Beginners 1 03-20-2009 10:50 AM
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
This project has begun! Village Idiot TalkPHP Developer Team 40 01-01-2009 04:29 AM
Securing your MySQL Queries with Sprintf Wildhoney General 26 03-18-2008 06:52 PM
Error in connecting to MySQL via PHP EyeDentify MySQL & Databases 0 01-03-2008 01:06 PM


All times are GMT. The time now is 05:02 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design