开发者

displaying HTML with PHP & MYSQL

displaying html problem with php & mysql

Hi basically i have a quick mysql_fetch_array script to display the contents from the db like below:

$sql_select_jobs = $db->query("SELECT * FROM `probid_jobs`");
while ($jobs_found = $db->fetch_array($sql_select_jobs)) {
$template_output .= "<div class=\"listed-jobs\" style=\"border: 1px solid gray; border-bottom: 0px; padding: 20px;\">"; 
$template_output .= "Job Title: " . $jobs_found['job_title'] . "<br />"; 
$template_output .= "Location: " . $jobs_found['location'] . "<br />"; 
$template_output .= "Salary: " . $jobs_found['salary'] . "<br />"; 
$template_output .= "Date Posted: " . $jobs_found['date'] . "<br /><br />"; 
$template_output .= "Description: " . $j开发者_高级运维obs_found['description'] . "...<a href=\"\">more</a><br />"; 

$template_output .= "</div>";
} 

however the output would look like this:

Job Title: fff
Location: ff
Salary: fff
Date Posted: 18/06/10
Description: <b>fffffffffff <i>fffffffffffffffffff</i><br></b>...more

as you can see the description html from the db isn't getting formatted as html, for some reason it is getting escaped.


Change the line:

$template_output .= "Description: " . $jobs_found['description'] . "...<a href=\"\">more</a><br />"; 

with:

$template_output .= "Description: " . html_entity_decode($jobs_found['description']) . "...<a href=\"\">more</a><br />"; 

More Info:

http://www.php.net/manual/en/function.html-entity-decode.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜