Jump to content

[SOLVED] [PHP] SQL table content in HTML format


Killer2

Recommended Posts

I use this code to display content on my page.

 

<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {die('Could not connect: ' . mysql_error());}
mysql_select_db("databasename") or die ("DB select failed - " . mysql_error());

$query = "SELECT columname2 FROM table WHERE columname1 = '1' ";
$result = mysql_query($query) or die("Query failed ($query) - " . mysql_error());
if(mysql_num_rows($result))
{
   while($row = mysql_fetch_assoc($result))
   {
      $data = $row['columname2'] ;
     echo ("$data");
   }
}

else
{
   echo "<p>No matches were found in the database for your query.</p>\n";
}
mysql_close($link);
?>

 

When database has an HTML code it won't display the content in HTML format.

 

Example:

 

When database table has <a href="http://www.website.com">website</a>

 

It should display only "website" with the hyperlink but it displays the complete HTML code. :(

 

My table looks like this:

25an4uh.png

 

Simple: I just want to export table data in HTML format.

What does a "view source" of the page in your browser show?

 

About the only reasons would be if htmlentities() was used on it or it is inside of some other HTML tags that prevents it from being rendered by the browser.

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.