Jump to content

Html_Entity_Decode


Travist6983

Recommended Posts

Hello -

 

I am trying to view a table in database that were entered as from a wysiwyg editor. When i export the data it isnt really readable. So i found this little script and was trying to output the data so i could copy it to excel.

 

i am able to get the data out but then it looks like this...

 

<p class="body"> <span style="font-size: 14px;"><span style="color: rgb(0, 0, 255);">Features:</span></span></p> <p> <span style="font-weight: bold;">• Over-sized 0.58" ID for high flow<br /> • Heavy duty 0.25" wall thickness for durability<br /> • Self-weighted for easy installation<br />

 

So i am trying to output that data without all of the HTML tags using the html_entity_decode, can anyone see where i am going wrong with the below code?

 

<?php 


// set database server access variables: 
$host = "localhost"; 
$user = "*****"; 
$pass = "********"; 
$db = "************";


// open connection 
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 


// select database 
mysql_select_db($db) or die ("Unable to select database!"); 


// create query 
$query = "SELECT * FROM product_description"; 


// execute query 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 



$html_decoded = utf8_encode(html_entity_decode($row[6]));


// see if any rows were returned 
if (mysql_num_rows($result) > 0) { 
   // yes 
   // print them one after another 
   echo "<table cellpadding=10 border=1>"; 
   while($row = mysql_fetch_row($result)) { 
       echo "<tr>"; 
       echo "<td>".$row[2]."</td>"; 
       echo "<td>".$html_decoded."</td>"; 
       echo "<td>".$row[6]."</td>"; // This outputs the row to look something like this [color=#000000][font=Times][size=1]<p class="body"> <span style="font-size: 14px;"><span style="color: rgb(0, 0, 255);">Features:[/size][/font][/color]
       echo "</tr>"; 
   } 
   echo "</table>"; 
} 
else { 
   // no 
   // print status message 
   echo "No rows found!"; 
} 


// free result set memory 
mysql_free_result($result); 


// close connection 
mysql_close($connection); 


?>

Link to comment
Share on other sites

Thanks for replying Christian -

 

is this the line you are talking about?

 

[color=#000000][size=2]echo [/size][/color][color=#008800][size=2]"<td>"[/size][/color][size=2][color="#666600"].[/color][/size]html_entity_decode($row[6])).[color=#008800][size=2]"</td>"[/size][/color][color=#666600][size=2];[/size][/color][color=#000000][size=2] [/size][/color]

 

Thanks!

 

I tried it with out the utf8 stuff

$html_decoded =  html_entity_decode($row[6]);

 

But that didnt work either... I am not a PHP guy i know just enough to be dangerous...

 

Do i even need to decode it and save it in a variable? or can i do something like this....

 

html_entity_decode($row[6])

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.