dean.vaughan
dean.vaughan

Reputation: 31

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: " . $jobs_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.

Upvotes: 2

Views: 124

Answers (1)

Sarfraz
Sarfraz

Reputation: 382616

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

Upvotes: 6

Related Questions