PHP text scroller?

jancz3rt

New Member
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
 

jnjc

New Member
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
 

AE7

New Member
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

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?
 

jancz3rt

New Member
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.

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?

Yes, that is correct.

JAN :D
 
Last edited:

jancz3rt

New Member
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
 

jnjc

New Member
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...
 

jancz3rt

New Member
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:

jancz3rt

New Member
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:

jnjc

New Member
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).
 

jancz3rt

New Member
Hi

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).

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
 
Top