avoid escape $this->db->get(); |
[eluser]luca89pe[/eluser]
Hi, i have a database with products. It contains: photo, name and a description of each product. I need to print that in a view, i got results with: Code: $this->db->get("mytable"); Code: for example: Code: <br /> Code: 003810391849.<br /> product description Thank You, Luca
[eluser]TheFuzzy0ne[/eluser]
I don't quite understand what you mean. I've never had this problem myself. Please post your view, and we can take it from there.
[eluser]luca89pe[/eluser]
Thank you for reply, i'll post all. I have a field in mysql table like this: Code: codice BEG001T90F800 Code: <?php Code: <section id="productShow"> Now, i want it prints obmitting the BR tag, and translate it with a newline: Code: codice BEG001T90F800 Code: codice BEG001T90F800 Thank you, Luca
[eluser]Herlevsen[/eluser]
You need to use the html entities for the tags. have a look here http://www.w3schools.com/html/html_entities.asp. Best practice would be to store it with the html entities in your database if thats always how you want to output it, IMO. But you could also do it on output by using either htmlspecialchars or htmlentites. http://php.net/manual/en/function.htmlentities.php http://php.net/manual/en/function.htmlspecialchars.php
[eluser]TheFuzzy0ne[/eluser]
Where in your view does this problem occur? Is it when you echo $collezione[0]->descrizione? It looks to be like the output is being escaped, but I don't understand where. From what I can see, you're just echoing the output, it's not actually being passed through any CodeIgniter functions.
[eluser]Herlevsen[/eluser]
I must have been very tired when i wrote my reply. I see now that you dont want to output the <br>, but just want a new line, when i thought it was the opposite (which seemed pretty strange). It is your jquery that escapes it, when you use the text method Code: $("#prodName").text($(this).attr("data-nome")); Instead you need to use the html method http://api.jquery.com/html/
[eluser]luca89pe[/eluser]
[quote author="Herlevsen" date="1369388001"]I must have been very tired when i wrote my reply. I see now that you dont want to output the <br>, but just want a new line, when i thought it was the opposite (which seemed pretty strange). It is your jquery that escapes it, when you use the text method Code: $("#prodName").text($(this).attr("data-nome")); Instead you need to use the html method http://api.jquery.com/html/[/quote] omg, that's all! thank you!!!! i tought codeigniter was the one that escaped the text, instead of jquery! Thank's to TheFuzzy0ne too, but Herlevsen centered the problem!!!!!!! Thank you guys!!! ![]()
[eluser]Pert[/eluser]
Or you can always use typeography helper and not save html code in database at all: http://ellislab.com/codeigniter/user-gui...elper.html |
Welcome Guest, Not a member yet? Register Sign In |