TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Formatting Flash/SQL News

Page: 1 Reply
May 14th 2004#150477 Report
Member since: Apr 25th 2003
Posts: 1977
Before I can import my news into flash, i need to format it first. Before converting to sql, everything was stored in a text file......so i just typed everything by hand. Now that im converting to sql......im kinda stumped on the best way to format the text. I could just add the formatting in the database and just echo everything out to flash.....or to keep the database clean I could format everything with php and then echo it back to flash. Which way would be the best?

Adding the formatting to the db would be easiest. For the 2nd way i would have to pull the news into an array, then create a loop for each row to wrap the appropriate tags around each element?

My formatting is; break DATE - Bold TITLE /bold break STORY and date/title/story are in my db
Reply with Quote Reply
May 14th 2004#150479 Report
Member since: Nov 26th 2001
Posts: 2586
For those types of displays you can also use a while loop:
[php]
while ($news = mysql_fetch_array($results, mysql_assoc)){
print $news[Date].' - '.$news[Title].'

'.$news[Story].'

';
}
[/php]

Database hold raw data, and not formatted. You can set what kind of data it is, ie. VARCHAR, INT, etc... So you will need php to wrap the text into a format from the raw data.

Depending on what version of Flash you are working with, Flash can use external styles sheets as well. Also you have the option of using dynamic text boxes which you can import from mysql via php. That way you can set different fonts, font weight, etc.

I am not sure Flash can connect directly to a database without a serverside language. But I could be wrong on this...
Reply with Quote Reply
May 14th 2004#150482 Report
Member since: Apr 25th 2003
Posts: 1977
whoa. kick ass. That was waaaaaay easier than i was trying to make it. Thank you!!

Now the while loop works because the fetch_array....unless its false goes to the next row until false stops the loop? It worked.....im just making sure i fully understand why.

As to external sheets......i need to upgrade for that :-( . That probably would have helped. About the dynamic box, im only using 1 for all text (keeps the alignment of everything perfect no matter the lenght of text) so i gotta do all the formatting outside first. But thats not a problem anymore cause this worked perfect!!
Reply with Quote Reply
May 14th 2004#150505 Report
Member since: Nov 26th 2001
Posts: 2586
exactly. Just keeps looping until the array is at the end.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum