This is probably a pretty basic question, but I don't know much about PHP. I'm familiar with a few other languages, though, so I understand how variables and triggers work.
What I'm trying to do for my site is have a text variable set on the page, that will change based on when I tell it to.
Basically, what I'm doing is having a row of pictures, and mouse-overing one of them will display a description, using the text variable...
Is this possible with PHP?
Thanks for any help,
Scott
Question regarding text as a variable...
Moderator: General Moderators
-
Staleycantrell
- Forum Newbie
- Posts: 2
- Joined: Wed Nov 23, 2005 12:46 am
-
Staleycantrell
- Forum Newbie
- Posts: 2
- Joined: Wed Nov 23, 2005 12:46 am
The first thing to understand about PHP is it is a Server side language. This means, even though your your page will have PHP code on it, and the user 'looks' at that page, the PHP code is not passed to the client.
This means that dynamic coding, such as you are asking for, cannot be done by PHP without communications between the user agent (client browser) and the server.
PHP's primary function in life is to generate output that is sent to the client, more specifically, it generates output that is interpreted by the client. This means that part of that output can be JavaScript, so you can dynamically generate JavaScript for your page and the Client's browser will interpret and if it is 'correct' run it
Now for your question - could you specify what, or rather where you want this text to appear?
If you want to appear in a 'balloon' box, then you can use the <img> alt attribute as most browsers will display this text when the user places their mouse cursor over the image. This is however not the intended use of the alt attribute, but is probably the most popular use. (It's intended use is as alternative text, i.e. text that is to be used when the picture cannot be displayed for whatever reason).
If you want the text to appear, say in a seperate <label> (for example) then you will need to use JavaScript to change the value of the <label> (i.e. DHTML).
This means that dynamic coding, such as you are asking for, cannot be done by PHP without communications between the user agent (client browser) and the server.
PHP's primary function in life is to generate output that is sent to the client, more specifically, it generates output that is interpreted by the client. This means that part of that output can be JavaScript, so you can dynamically generate JavaScript for your page and the Client's browser will interpret and if it is 'correct' run it
Now for your question - could you specify what, or rather where you want this text to appear?
If you want to appear in a 'balloon' box, then you can use the <img> alt attribute as most browsers will display this text when the user places their mouse cursor over the image. This is however not the intended use of the alt attribute, but is probably the most popular use. (It's intended use is as alternative text, i.e. text that is to be used when the picture cannot be displayed for whatever reason).
If you want the text to appear, say in a seperate <label> (for example) then you will need to use JavaScript to change the value of the <label> (i.e. DHTML).