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.

Link to comment
Share on other sites

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.