babydolphin Posted October 16, 2008 Share Posted October 16, 2008 i have tried to display the data from one table. but the php is not displaying the data from the table. please advise anyone. Codes is as below : <?php include ("login.php"); $query = "select * from news"; $result = mysql_query($query); if(!$result) { die("could not query the database: <br>" .mysql_error()); } echo "<table><tr><td>Date</td><td>Description</td>"; while($rowsql=mysql_fetch_array($result)) { echo $result_row["dates"]."</td>"; echo $result_row["news_desc"]."</td>"; echo $result_row["news_details"]."</td></tr>"; } mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2008 Share Posted October 16, 2008 <?php include ("login.php"); $query = "select * from news"; $result = mysql_query($query); if(!$result) { die("could not query the database: <br>" .mysql_error()); } else if(empty($result)||$result==""){ die("The MYSQL columns are empty!"); } echo "<table><tr><td>Date</td><td>Description</td>"; while($row=mysql_fetch_array($result)) { echo $row["dates"]."</td>"; echo $row["news_desc"]."</td>"; echo $row["news_details"]."</td></tr>"; } mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
.josh Posted October 16, 2008 Share Posted October 16, 2008 darkfreaks your code doesn't really fix the problem, though it might possibly point him/her in the right direction. That is, it just adds an extra condition in there to see if any results are returned. If it's being triggered then he may come a step closer to figuring out what the problem really is. babydolphin, are you not getting any error messages? If not, then try what darkfreaks suggested; is the "The MYSQL columns are empty!" message being displayed? Check to make sure your column names are correct in your $row[...] echoes. For example, should they be capitalized? Maybe a stupid question, but are you sure there is data to be retrieved? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2008 Share Posted October 16, 2008 that was my intend crayons to help her figure out the problem not solve it for her Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 16, 2008 Share Posted October 16, 2008 <?php include ("login.php"); $query = "select * from news"; $result = mysql_query($query); if(!$result) { die("could not query the database: <br>" .mysql_error()); } echo "<table><tr><td>Date</td><td>Description</td>"; while($rowsql=mysql_fetch_array($result)) { echo $rowsql["dates"]."</td>"; echo $rowsql["news_desc"]."</td>"; echo $rowsql["news_details"]."</td></tr>"; } mysql_close($connection); ?> in your while loop you had one variable, and you called a completely different variable, kinda like you ripped off this code from a tutorial. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.