Font control when loading dynamic content with PHP/MySQL

Hi,

As a designer - not really a programmer- I have a few questions on typography.
In an.swf file i have a texteditor with which i can HTML format text, using a font of my choosing -I ask this specifically for using non-system fonts.
My goal is to export this formatted text to a MySQL database via PHP, and later have it read back in, while maintaining its original formatting AND (non-system)font face.
I wondered if this is at all possible, and if yes:How?

When you modify the typo of text, you have to consider that there is two elements to take in consideration. The first one is the text, the string itself. For example, “Hi man” in Arial means the same thing as “Hi man” in Times New Roman.

The second thing is the typo. It’s the “style” of the string.

In your case, you want to send a string, attach it a typo and be able to reload it.

I dont really understand entirely what you want to do. Do you want to…

1- Send an html string to a db, read it back and load it in an html?
2- Send a string with the format that YOU decided (for example, all html in your text editor would be yellow) ?

If your case is Question 1, it’s easy : just send as a string to the db your entire text, with the html brackets.

If your case is Question 2, it’s HARD. Real hard, but it can be done. What you will have to do is put your entire text (what the user have done in your editor) in a single string. After, you will have to modify it in order to put you “personnal markers” that, after loading it from the db, will tell you what to do at specific moment in your string (ie jump a line, change color, etc).

This process is called “parsing”.

Let’s take an example. You have this html code :

hello my name is < g1 >Bobby< /g1 >.

(okay, < g1 > means nothing, but you get the point.)

I suppose that what you want to do, is but “< g1 >Bobby< /g1 >” in yellow, for example.

You will have to put the entire text in a string and modify it in order to add something like :

hello my name is [this_clr=yellow]< g1 >Bobby< /g1 >[stop_clr].

While you will read back the string from the db, you will know that after “[this_clr=” there is the name of the color until you hit the next closing bracket, ‘]’. The following text will be of that color, until you read “[stop_clr]”.

For parsing, you will need to learn how to use all the methods of the String type (substr, concat, charAt, etc…)

As you can see, that’s not an easy job.

But maybe I don’t answer to your question? Maybe what you really want to do, is to always use the same customized type for all code in < g1 > and < /g1 >, for example. If THAT is your case, simply send your html string to the db. When you will retreive it back, parse your string using the substr() function, for example. “Intercept” the < g1 > code and when you will read it, change the color of the text in your swf until the next < /g1 >.

Man, you have an interresting project but not the easiest one !

I hope that my explanation have help you.

Oh and btw, ALWAYS use a font like Courrier for html (or any coding editor) otherwise you won’t be able to indent correctly your code.

Hi Voglio,

Thanks for your reply.

Your second suggestion, the “easy” one (well, not for me) seems like a plausable one to me.
As i said i am not a programmer, but, I guess, since the chosen font is already embedded in the the textfield in the .swf, (and in my case, there is only one font going to be used in this textfield) it does not need to be stored in the database. Only the html formatting has to be preserved, am i right?
I wanted to attach the .fla file to show you what i mean, but it is just over the allowed filesize to be posted in this thread, but i am happy to send it to you by email if you want. Let me know if you do.
I hope you can help me out with some code, because i don’t know how to get the contents of my textfield to the database.

Thanks,
Rolf

I hope you can help me out with some code, because i don’t know how to get the contents of my textfield to the database.

Check out the new tutorial on Kirupa.com, “AS and PHP made Easy”. I’ve written it, this should help you to transfer your info from AS to your DB.