View Full Version : Cross Browser marquee moded to read DB values

06-15-2007, 04:11 PM
Hello, here's the link of the script: http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm

i modded it to show mssql values (table), the problem is, it shows only the first row, is there a way to display all the rows contained on that table (10)?

my mod atm is smth like this:

//Before javascript starts.
$mess1 = mssql_query("SELECT TOP 10 idname, name, message FROM mmessages ORDER BY idname DESC");
$fetch_mess1 = mssql_fetch_row($mess1);

then, inside javascript i added a var

var m1=\"<span class=style3>\"+\"$fetch_mess1[1]\"+\"</span>: \"+\"$fetch_mess1[2]\"

and then i changed here:

var marqueecontent='<nobr><font face=\"Arial\">'+m1+'</font></nobr>'

This mod shows me the name and message from that user, but the problem is it only shows one row from the table, on this case the last one (ORDER DESC).

Anyone knows how to show all the rows form the table? if there's 10 rows, show 10 messages, if there's 25 rows, show 25 messages...

Thanks you!

06-16-2007, 04:21 AM
Anyone? Please!

06-17-2007, 06:48 AM
As I'm not familiar with MS SQL syntax, I can only talk in generalities here. As far as the marquee script is concerned, what you want to do is dynamically write out the variable "marqueecontent" so it's set with the contents to show. In PHP, it looks something like this:

$data= mysql_query($query);
echo "var marqueecontent='<nobr><font face=\"Arial\">" . addslashes($output) . "</font></nobr>'";

This results in something like the following displayed when you view the browser source:

var marqueecontent='<nobr><font face="Arial">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider linking to us by <a href="../link.htm">click here.</a> Enjoy your stay!</font></nobr>'

In other words, your goal is simply to get the server to output the JS variable "marqueecontent" exactly as it appears inside the script and set with the contents to show. Just looking at your SQL syntax, it doesn't seem you have the correct syntax to retrieving all of the rows' data and appending it to a single variable.