Travist6983 Posted December 26, 2012 Share Posted December 26, 2012 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/272388-html_entity_decode/ Share on other sites More sharing options...
Christian F. Posted December 26, 2012 Share Posted December 26, 2012 If you read through your code, line by line in detail, you should be able to spot the problem yourself. Make sure you ask yourself "what, exactly, does this line do/mean?" I can give you one hint: From where do you get the content you're trying to decode? Quote Link to comment https://forums.phpfreaks.com/topic/272388-html_entity_decode/#findComment-1401415 Share on other sites More sharing options...
Travist6983 Posted December 27, 2012 Author Share Posted December 27, 2012 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]) Quote Link to comment https://forums.phpfreaks.com/topic/272388-html_entity_decode/#findComment-1401423 Share on other sites More sharing options...
Travist6983 Posted December 27, 2012 Author Share Posted December 27, 2012 BAHAHA Thanks Christian For pushing me to find the answer my self! I got it to work! Have a great holiday! Travis Quote Link to comment https://forums.phpfreaks.com/topic/272388-html_entity_decode/#findComment-1401425 Share on other sites More sharing options...
Christian F. Posted December 27, 2012 Share Posted December 27, 2012 Hehe, you're welcome. Glad I could help. Quote Link to comment https://forums.phpfreaks.com/topic/272388-html_entity_decode/#findComment-1401426 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.