bcatt Posted May 21, 2008 Share Posted May 21, 2008 I'm wondering if it's possible to store code as table data. Preferably XSL or CSS code. Example cell data: <format1>I want this text to be rendered to the user as blue, italic, 14pt Arial</format1> <format2>And this text will be rendered to the user as orange, bold, 12pt Helvecta</format2> So that if I use php to pull this entry from the database to display on the page, my client-side css or xsl can then format these items based on their enclosing tags. Someone told me that if I don't do it right I will mess things up. I'm using SQL-front to manage my database, and using V5.0 of mySQL (within V2.0 of easy php). Thanks in advance. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted May 21, 2008 Share Posted May 21, 2008 your looking at something similar to BBCode but I think what you want to do is use php more along the limes i.e you input those rows into mysql <format1>This text</format1> <format2>More Text</format2> and then you use a php function to do a replace to replace <format1> with <span class="format1"> Quote Link to comment Share on other sites More sharing options...
bcatt Posted May 21, 2008 Author Share Posted May 21, 2008 Oh, thanks. I'm completely new to SQL/PHP (on my second day of figuring it out), so I haven't learned all of what I can do with them yet. So, just to make sure I'm understanding properly, having html-like tags in mySQL table cells isn't going to cause any problems with my database? And I can easily manipulate these "markers" once the data has been pulled? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted May 21, 2008 Share Posted May 21, 2008 take this <?php function bb2html($text){ $bbcode = array("<", ">", "[list]", "[*]", "[/list]", "[img=", "]", "[b]", "[/b]", "[u]", "[/u]", "[i]", "[/i]", '[color="', "[/color]", "[size=\"", "[/size]", '[url="', "[/url]", "[mail=\"", "[/mail]", "[quote]", "[/quote]", '"]'); $htmlcode = array("<", ">", "<ul>", "<li>", "</ul>", "<img src=\"", "\">", "<b>", "</b>", "<u>", "</u>", "<i>", "</i>", "<span style=\"color:", "</span>", "<span style=\"font-size:", "</span>", '<a href="', "</a>", "<a href=\"mailto:", "</a>", "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>", '">'); $newtext = str_replace($bbcode, $htmlcode, $text); //$newtext = nl2br($newtext);//second pass return $newtext; } ?> and replace the tags with a bunch of <span class="formatX"> </span> Quote Link to comment 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.