# Scrolling text loaded from mysql

**URL:** <https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723>\
**Category:** flash\
**Created:** [August 17, 2003, 6:00pm UTC](https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723 "2003-08-17T18:00:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danii](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Danii](https://forum.kirupa.com/u/Danii)\
**Post date:** [August 17, 2003, 6:00pm UTC](https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723/1 "2003-08-17T18:00:19Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 17, 2003, 6:29pm UTC](https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723/2 "2003-08-17T18:29:49Z")

</div>

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](https://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](http://www.yourserver.com/script.php)”);  
}[/AS]

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

```php

<?
$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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 17, 2003, 6:35pm UTC](https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723/3 "2003-08-17T18:35:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 17, 2003, 6:54pm UTC](https://forum.kirupa.com/t/scrolling-text-loaded-from-mysql/28723/4 "2003-08-17T18:54:29Z")

</div>

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??  
-\_\_\_\_\_\_\_\_\_-’
