Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.