realUser404
realUser404

Reputation: 2231

Display correct characters when Select on column containing HTML

In my database I store some html code (from CKEditor), and I would like to be able to check these values in PhpMyAdmin.

There is one small problem : the HTML is written in french so there are a lot ar &eacute: or other kind of html characters that make the values hard to read.

I know there are settings to avoid CKEditor replacing the characters with &eacute:, but I do not want to change anything in the code or configuration tight now.

Is there any MySQL command that would allow to display the text correctly?

Note : doing a str_replace or kind is not wanted.

Edit : For exemple for an element stored as follow :

<div>
    &eacute:l&eacute:phant
</div>

I would like to read in my result column :

<div>
    éléphant
</div>

Upvotes: 2

Views: 653

Answers (2)

Isaac Bennetch
Isaac Bennetch

Reputation: 12422

This is easily accomplished with phpMyAdmin's transformation feature.

My answer assumes you already have a properly configured phpMyAdmin Configuration Storage, if not you just have to create the tables by editing the file in examples/create_tables.sql to set a username, database name, and password, then import that to your MySQL server. Edit config.inc.php to add the directives you can find listed beginning at http://docs.phpmyadmin.net/en/latest/config.html#cfg_Servers_pmadb .

Before:

Before transformations

Anyway, edit your table by going to the Structure tab.

Structure tab

Click the pencil icon/Change link for the column(s) containing the HTML entities.

On the resulting page, look for the "Browser display transformation" dropdown. One of the built in transformations is exactly what you're after: "Text/Plain: Formatted"

Text/Plain: Formatted dropdown

Click Save, then you can Browse the table and should see the transformed output.

After:

After transformations

Upvotes: 0

javier_domenech
javier_domenech

Reputation: 6263

I'm afraid there is no way to do directly what you are asking for.

The best way I've found would be to create a function which decodes the text, and then use it in select statements:

mysql> SELECT HTML_UnEncode('Dr.H&uuml;bner');
+---------------------------------+
| HTML_UnEncode('Dr.H&uuml;bner') |
+---------------------------------+
| Dr.Hübner |
+---------------------------------+ 

Here is the link to that function:

http://forums.mysql.com/read.php?98,246527,246527

Upvotes: 3

Related Questions