SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting HTML in MySQL Tables

    I've learned that if you insert <em>Nickname</em> in a cell in a MySQL table, it will display the word Nickname italicized. So I'm now inserting lots of HTML in my MySQL tables!

    I just wondered if this is standard practice, or is there a way better to do it?

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it would be best to only add the html decoration AFTER you pull that info out of the database and fill it in the page you want to show.


    Just think about this ... right now you want all the nicknames on your site to be shown in italic ... but next year you do a redesign of your site, and you think it would suit better if all nicks would be shown in bold instead of italic .. and then you look at your database with thousands of nicknames that are italic ... oops !

    ofcourse, you could filter those <em> tags out of it, or use a function to replace them with <b> .. but still, it would not be very efficient.


    So I'd say that the standard practice is to avoid any html that early, and to only add it on the end of the process , so when a page is generated with that info.

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by odoisc
    I think it would be best to only add the html decoration AFTER you pull that info out of the database and fill it in the page you want to show.


    Just think about this ... right now you want all the nicknames on your site to be shown in italic ... but next year you do a redesign of your site, and you think it would suit better if all nicks would be shown in bold instead of italic .. and then you look at your database with thousands of nicknames that are italic ... oops !

    ofcourse, you could filter those <em> tags out of it, or use a function to replace them with <b> .. but still, it would not be very efficient.

    So I'd say that the standard practice is to avoid any html that early, and to only add it on the end of the process , so when a page is generated with that info.
    Thanks for the tip, but how would you add html AFTER you've made your table?

    Also, how would you replace them with <b>, or whatever? That's another question I'm exploring - how to do search and replace on MySQL tables.

    Thanks!

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i would just go ahead and store the html into the database

    a bazillion sites do this, and there's a reason
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •