[Webinar] Streamline your web hosting managementRegister Today


Storing text formatting such as superscript and subscript in SQL Server 2005 using PHP

Posted on 2008-02-01
Medium Priority
Last Modified: 2013-12-12
I have a html form where people submit among many things an abstract for a presentation. I've come across mathematics persons who's abstracts call for super/subscripts in the text to be meaningful and correct.

I have an idea of how to do this, but was going to see if their is a easier way any professionals may know about. The page is xhtml/javascript/css, the abstracts (fancy word for description) are typed into a textarea and the form sends POST data to PHP 5.

My though was to either inform the user or provide buttons for "begin subscript" "end subscript" etc. which insert right where their cursor is "[sub]" "[/sub]" (you can imagine the same for superscript). I can't/don't wish to use regular html/xhtml tags because I strip tags on the server side as to not allow jokers to format things interestingly when page data is redisplayed. Just before the string is stored in database, along with a function to escape single quote, I would add in regular expression replace for "[sub]" and "[/sub]" etc. to become "<sub> and "</sub" etc.

This also creates more peculiarities in the fact that at a certain point I would have to go through a take out any formatting done for web displaying and change it to what would be needed for printing in a booklet.

What have others done? Does this sound like a decent approach?
Question by:justinvoels
  • 3
LVL 19

Accepted Solution

LordOfPorts earned 800 total points
ID: 20800509
That approach would work, if you are using the strip_tags($text); PHP function http://us2.php.net/strip_tags to remove HTML tags it has a second optional parameter that allows you to specify which tags are allowed, e.g.:

strip_tags($text, '<sub><sup>');

This way the user or your buttons could use the real tags for editing. Another option is to use a rich text box such as TinyMCE http://tinymce.moxiecode.com/ which come with special buttons for super- and subscript, it is very easy to integrate with your existing page and shows the user actual superscripted/subscripted tags instead of the HTML tags.

Author Comment

ID: 20800637
Could anyone elaborate on the storing of this data in a database?

Author Comment

ID: 20800641
By that I meant using tinyMCE

Author Comment

ID: 20800668
Haha, my apologies, next time I promise I will click the link and read it first, I caught the name a bit late too.

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question