English 中文(简体)
如何使来自数据库的html平流
原标题:How to parse html coming from database

How do I do output HTML that comes back from database after it s been decoded back from html entities to HTML. I m learning how to use Tinymce and I m stuck. I can t echo the HTML because it just prints it in the page. Do I have to look on the DOM side with DOMDocument? I ve seen this question asked on different sites but never answered clearly.Or maybe i m such a newbie that the answer is right in front of me. Thanks!

<?php
$page_title = "Brian Aylward comedy website";
$current_page = "home";

include("site_admin/tinymce/shows/db.php");
doDB();

$get_contents_sql = "SELECT * FROM tinymce_contents";
$get_contents_res = mysqli_query($mysqli, $get_contents_sql)
or die(mysqli_error($mysqli));

if ($get_contents_res = mysqli_query($mysqli, $get_contents_sql)) {

while ($row = mysqli_fetch_assoc($get_contents_res)) {

   $contents = $row[ contents ];

   $fill_block = html_entity_decode($contents);
  }
}

mysqli_close($mysqli);


include_once ./includes/header.php ; ?>


<span id="mikemouth"></span>
<div id="jacket">

<h2 id="showtitle">LIVE DATES</h2>
<div id="shows">


    <div class="shows_content">

<?php

//I want to output the HTML here but can t use echo $fill_block; since it will print
//the HTML in the webpage when I want it parsed as HTML.Does it make sense?

?>
问题回答

如果你将超文本储存在数据库中,则在标本上打印时,需要使用html。 虽然我建议你不要首先把超文本与编码标签放在一起。

请允许我指出,在通过网站后,你将以下超文本储存在数据库中:

<a href="http://hello.com">hello</a>

如果你印刷,你将获得这样的信息:

&lt;a href=&quot;http://hello.com&quot;&gt;hello&lt;/a&gt;

To use it properly in TinyMCE you would need to pass it through html_entity_decode() which will produce the right markup.

现在请在数据库中说:

<a href="http://hello.com">hello</a>

It will probably be stored looking like this:

<a href="http://hello.com">hello</a>

你们需要使用

你可以使用一个文字区在浏览器上显示html。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签