Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 01:47
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  Formatting Help!
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Formatting Help!  (Read 1056 times)
andrew knapp
Server what's that
*
Posts: 2



View Profile Email
« on: 11/24/03, 09:45 »

So far, I've managed to bring an entry into Flash from MySQL via PHP.  here: http://www.andrewknapp.com/temp/flashnews/flashnews.swf

It is showing only one entry.  Could anyone tell me how I would reformat what I have to make it alternate, in the same window, between Date and Message?  Just like anyother news format.  Here is the code I have thus far:

PHP:
Code:
<?

include("common.php");

   mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());

   mysql_select_db($db_name) or die(mysql_error());

   $query = "SELECT * FROM tempernews ORDER BY id ASC";
   
   $result = mysql_query($query) or die ("Error");
   
   $num_rows = mysql_num_rows($result);
   
   for($i=0;$i<$num_rows;$i++){
   
      $row = mysql_fetch_array($result);
            
      $news = "news$i";
      $news = $row['message'];
      
      $date = "date$i";
      $date = $row['date'];
      
      print("&news$i=$news");
      print("&date$i=$date");
      
   }
   
?>


FLASH:
Code:
System.useCodepage = true;
format = new TextFormat();
testo.html = true;
function formatText(textBox, ita, siz, Bold, colour) {
   format.italic = ita;
   format.size = siz;
   format.bold = Bold;
   format.font = "Arial";
   format.align = "left";
   format.color = colour;
   textBox.setTextFormat(format);
}
testo.text = "Loading news...";
formatText(testo, true, 10, true);
date.text = "Loading...";
formatText(date, true, 10, true, "0xFF0000");
temp = new LoadVars();
temp.load("flashnews.php");
temp.onLoad = function() {
   myArray = new Array();
   for (var a in this) {
       if (a != "onLoad") {
           myArray.push(this[a]);
       }
   }
   date.text = myArray[0];
   formatText(date, false, 10, true, "0xFF0000");
   testo.htmlText = myArray[1];
   formatText(testo, true, 10, true);
   var oldt = getTimer();
   var ok = true;
   var l = myArray.length;
   var i = 5;
};


Here's the Fla: http://www.andrewknapp.com/flashnews/flashnews.zip
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 11/25/03, 04:12 »

Check the output of the PHP file, you're overwriting variables and keeep all togheter. Should be:

for($i=0;$i<$num_rows;$i++){
 
     $row = mysql_fetch_array($result);
           
     $data = "news$i=$row['message']&date$i=$row['date']&";
     print("$data");    
}

Jorge

Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!