PHP text scroller?

Discussion in 'Scripts' started by jancz3rt, Jul 15, 2008.

to remove all ads.
  1. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hey guys,

    Would any of you know of any PHP script which would allow me to upload a .txt file with text which would then scroll itself (I need an Updates section) which I could place at the top of www.kaffkarna.cz that I am working on. Many thanks.

    JAN :D
     
  2. jnjc

    jnjc New Member

    Messages:
    493
    You will only need php to load the text, use:
    file_get_contents('filename');

    then use the marquee tag to display the scrolling text

    <marquee direction="right"> Your text </marquee>

    Do a google on the marquee tag to get all the parameters.

    So in theory (which means this is off the top of my head and not tested), you could do something like the following:

    <marquee direction="right"><?php echo file_get_contents('filename'); ?></marquee>

    You could also put a div inside the marquee taq and use an ajax call to put the contents of the file into the div (that would take out the need for php altogether).

    HTH,
    JC
     
  3. AE7

    AE7 New Member

    Messages:
    53
    Well said...

    jan, just out of curiosity, you are planning to upload a .txt of updates to your hosting server periodically to display on the site, no?
     
  4. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hi

    Thanks a lot guys, I will most likely be implementing changes you have suggested. In the meantime, please check www.kaffkarna.cz and let me know what you think about it.

    Yes, that is correct.

    JAN :D
     
    Last edited: Aug 19, 2008
  5. Kozmo

    Kozmo New Member

    Messages:
    3
    You could also use JavaScript to create some additional sweet text effects.
     
  6. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hmmm

    Guys, I have tried the following and it does not work, am I doing something wrong?

    Code:
    <html>
    <head>
    </head>
    <body>
    <marquee direction="right"><font color="#000000"><?php echo file_get_contents('test.txt'); ?></font></marquee>
    </body>
    </html>
    In theory, this should display the contents of the file "test.txt" no? Please help, I am kind of lost now.

    JAN :D
     
  7. jnjc

    jnjc New Member

    Messages:
    493
  8. jnjc

    jnjc New Member

    Messages:
    493
    Just had another thought, what is the name of the file you put this code in ? If it doesn't have a .php extension then it won't work...
     
  9. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hi

    Yes, you are correct. That was the problem. I saved it into a .html file. Thanks loads! This will come in very handy. I even noticed you can use tags and other funky things in the text file. That's great.

    JAN :D
     
    Last edited: Aug 20, 2008
  10. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hi

    Hi guys, the above script is functional but I cannot figure out how to make it work inside an HTML file (somehow embedding it). In other words, inside a DIV tag. I would appreciate any feedback as this is driving me crazy.

    Here's the code of the PHP file:

    Code:
    <marquee direction="right"><font color="#000000"><?php echo file_get_contents('test.txt'); ?></font></marquee>
    I have tried the following in my file to embed the PHP file in my HTML document:

    Code:
    <script language="php" src="scroller.php"></script>
    JAN :D
     
    Last edited: Sep 1, 2008
  11. jnjc

    jnjc New Member

    Messages:
    493
    As far as I know the only way for you to get this to work in it's original form is to put it in a .php file. That said, in reality all you need to do is rename your .html (or .htm) file to .php and it should work.

    I have never used the 'script language="php" ' approach so I don't know anything about it (my suspicion is that it won't work because to me that would be trying to execute the code client side whereas you need server side).
     
  12. jancz3rt

    jancz3rt New Member

    Messages:
    38
    Hi

    Thanks for your help. Since the client needed to see it in action, I have embedded it through the use of the <iframe> :) For now, it does its job.

    You can check it out on : www.kaffkarna.cz

    JAN :D
     

Share This Page