Results 1 to 3 of 3

Thread: Cross Browser marquee moded to read DB values

  1. #1
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Cross Browser marquee moded to read DB values

    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:

    Code:
    //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

    Code:
    var m1=\"<span class=style3>\"+\"$fetch_mess1[1]\"+\"</span>: \"+\"$fetch_mess1[2]\"
    and then i changed here:

    Code:
    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!
    Last edited by nicksalad; 06-15-2007 at 04:17 PM.

  2. #2
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Anyone? Please!

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    <?
    $data= mysql_query($query);
    $output="";
    while($d=mysql_fetch_array($data)){
    $output.=$d;
    }
    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:

    Code:
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •