I’m wondering if anyone knows how to preserve text formtatting when pulling data from a MySQl database. We have a db full of text sentences, and when we pull from this to put sentences in games, etc, all the formatting like bold, underlining or italics is lost. Is there a way to keep this?
How is the text formatted originally? SQL does not have any specification for styled text; all text data are stored in plain ASCII. If you must have formatting, you can store your text in psuedo-HTML.
We’re originally doing the formatting and typing in MS Excel. The formatting seems (if I remember right) to exist in the database once it’s pulled from the Excel sheets, but then disappears when we pull it out for games and quizzes on our web site.
As for psuedo-HTML, if you have any other specifics, I’d like to hear them, but I’ll pass this on to those more technically minded than I.
How, exactly, are you pulling the data from the spreadsheets into the MySQL server? I’m just a little confused about what you mean when you say, “The formatting seems…to exist in the database once it’s pulled from the Excel sheets…”
What database client are you using to put the data in there? Are you doing it directly from Excel (I dunno if that’s even possible; I don’t use Excel.)
My guess is you’re pasting from the spreadsheet into the DB client where the formatting is maintained, and then that formatting gets stripped when the data is actually saved to the DB.
You mentioned that this is for a web site, so the most obvious solution would be to convert your formatting to HTML and store it like that. For example, if you have an item that’s supposed to be bold, save it to the database as <b>this is the item</b>. I’m pretty sure Excel has a function for exporting stuff as HTML.
Hey, that makes sense. We’ll see if we can do that. Thanks for the tip.