Jump to content

table data not being displayed. PLease Help


babydolphin

Recommended Posts

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);

?>

<?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);
?>

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?

<?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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.