我已經在使用編輯器的mysql表中存儲了一些html代碼。它包含YouTube視頻的嵌入代碼,所以在mysql中列條目是這樣當從mysql獲取數據時,html標籤正在顯示
This is a hello text. <iframe width="560" height="315" src="https://www.youtube.com/embed/zAlX1V3lK5s"> </iframe><br>
我想提出一個jQuery的GET調用從MySQL得到這個數據,我已經使用這個代碼是
$.get(
'test.php',
function(response) {
console.log(response);
$('#test').html(response);
}
);
PHP代碼獲取結果是
mysql_connect("localhost", 'root', 'root');
mysql_select_db("dummy");
$rs = mysql_query("select dummy from demotable where id = xyz");
$r = mysql_fetch_array($rs);
echo $r['dummy']; //contains that string which includes iframe too
但是當我顯示結果的DIV那麼它是不是有顯示視頻,但它顯示的字符串,因爲它是我在前端獲取輸出格是
This is a strong beer. <iframe width="560" height="315" src="https://www.youtube.com/embed/zAlX1V3lK5s"> </iframe><br>
我怎樣才能得到視頻,而不是顯示源?
從[tag:php-5.5]開始,不推薦使用'mysql_ *'。所以改爲使用'mysqli_ *'或'PDO'。 [爲什麼我不應該在PHP中使用mysql_ *函數?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php/14110189#14110189) – mega6382
它只是一個例子,我正在使用蛋糕的PHP做的事情,但它仍然顯示字符串,而不是將嵌入代碼轉換爲視頻 –