Killer2 Posted August 2, 2009 Share Posted August 2, 2009 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: Simple: I just want to export table data in HTML format. Link to comment https://forums.phpfreaks.com/topic/168525-solved-php-sql-table-content-in-html-format/ Share on other sites More sharing options...
Killer2 Posted August 2, 2009 Author Share Posted August 2, 2009 bump please help Link to comment https://forums.phpfreaks.com/topic/168525-solved-php-sql-table-content-in-html-format/#findComment-889171 Share on other sites More sharing options...
PFMaBiSmAd Posted August 3, 2009 Share Posted August 3, 2009 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. Link to comment https://forums.phpfreaks.com/topic/168525-solved-php-sql-table-content-in-html-format/#findComment-889176 Share on other sites More sharing options...
Killer2 Posted August 4, 2009 Author Share Posted August 4, 2009 If I enter <b>bold text</b> in my SQL It won't be bold when render on browser and the browser source looks like this: <b>bold text</b> What can I do? Link to comment https://forums.phpfreaks.com/topic/168525-solved-php-sql-table-content-in-html-format/#findComment-890823 Share on other sites More sharing options...
Killer2 Posted August 4, 2009 Author Share Posted August 4, 2009 The problem has been solved! Thanks PFMaBiSmAd for mentioning "htmlentities". I googled and solved the problem. Thanks phpfreaks! You guys rocks! Link to comment https://forums.phpfreaks.com/topic/168525-solved-php-sql-table-content-in-html-format/#findComment-890868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.