Scrolling text loaded from mysql

I followed the tutorial but the scroller wont work with text loaded from a mysql server?
How do i get tht to work?
I know theres another thread here with the same question but theres no good reply to it…
:q: :q: :q:

This is a piece of code ahmed gave me. It worked fine ! Here I used a textfield called contentText. Just paste a scrollbar component to it and it should work.

[AS]
onClipEvent (load) {
contentText.condenseWhite = true;
contentText.html = 1;
lv = new loadVars();
lv.onLoad = function(success) {
if (success) {
i = this.i; //this.i is the variable loaded, i is the var of a textfield
inhoud.html = 1;
for (l=i; l>=0; l–) {
contentText.htmlText += this[“datum”+l];
contentText.htmlText += this[“inhoud”+l];
/* datum, inhoud and i (the first one, not the one from the for() loop are variables loaded from the database by the PHP script */
}
} else {
trace(“failed to load script”);
}
};
lv.load(“http://www.yourserver.com/script.php”);
}[/AS]

And this is the PHP script, debugged by Jubba :slight_smile: The vars are in a table called ‘yourtable’, inside the database ‘yourdatabase’.


<?
$l = mysql_connect("host", "username","password");
mysql_select_db("yourdatabase");

$q = "SELECT * FROM yourtable";
$r = mysql_query($q, $l);

if($r){
     $nrows = mysql_num_rows($r);

     $output="";

     for ($i=0; $i < $nrows; $i++){
         $row = mysql_fetch_array($r);

         $output .= "&i=".$i;
         $output .= "&datum".$i."=".$row['datum'];
         $output .= "&inhoud".$i."=".$row['inhoud'];
     }
     print $output;
}
else
{
     print mysql_error($l);
}



mysql_close($l);
?>

That should get it working :slight_smile:

you might want to use it without the ‘onClipEvent’ part if you’re assigning the script to a frame :slight_smile:

BIIIG thx for the code and all but…
im RLLY new to php and AS, so tht didnt make much sense to me =S =S =S

mind explaining a lil??
-_________-’