Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 12-31-2009, 08:44 PM   #1 (permalink)
enden
Junior Member
 
Join Date: Dec 2009
Posts: 2
Default Inline PHP in HTML

Hi,
I'm new here and to PHP, just trying to get some good PHP knowledge. It'd be nice if I could receive any sort of help.

I am having trouble making a code piece work:

PHP Code:
<?php
function onMouseOver()
{
    echo 
"<script type='text/javascript'>window.alert('Mouseover called')</script>";
}
?>

<a href='blahblah.php' onmouseover='"<?php onMouseOver() ?>"'> <img name="item1" src="../aboutus.bmp" /></a>
In the code above, I'm simply trying to call the function onMouseOver(); using the onmouseover property from href. The problem is that the window.alert function is being called when I enter the page when it is supposed to call the window.alert function when I mouseover the image?

I even tried to put the whole code in php:
PHP Code:
<?php
function onMouseOver()
{
    echo 
"<script type='text/javascript'>window.alert('Mouseover called')</script>";
}
?>

<?php echo "<a href='blahblah.php' onmouseover='".onMouseOver()."' > <img name='item1' src=../aboutus.bmp' /></a>" ?>
Still doesn't work? For some reason!

Any ideas, anyone?!

Edit: Nevermind, I found a workaround.

Last edited by enden; 01-01-2010 at 12:06 AM.. Reason: Figured it out
enden is offline   Reply With Quote
Sponsored Links
Old 01-01-2010, 12:50 AM   #2 (permalink)
mackson
Junior Member
 
Join Date: Dec 2009
Posts: 42
Default Re: Inline PHP in HTML

looking at the function i dont see the code is suppose to call the windows alert when the mouse is scrolled over.


if you can tell me what exactly you want to achieve I can try and code for you
mackson is offline   Reply With Quote
Old 01-01-2010, 05:01 AM   #3 (permalink)
enden
Junior Member
 
Join Date: Dec 2009
Posts: 2
Default Re: Inline PHP in HTML

I figured out what I need to do thanks!!
enden is offline   Reply With Quote
Old 01-06-2010, 05:56 PM   #4 (permalink)
vanguard
Junior Member
 
Join Date: Jan 2010
Posts: 4
Default Re: Inline PHP in HTML

for future readers, just to let you know that PHP is a server-side language. It cannot be activated from within an HTML document, it only runs when someone accesses a page, and is used to create dynamic contents on the page to send to the user. therefore, by calling the php function above, the code within the php function was executed and the <script>...</script> was added to the page before being sent to the user.
vanguard is offline   Reply With Quote
Old 01-07-2010, 11:46 PM   #5 (permalink)
ryanne
Junior Member
 
Join Date: Jan 2010
Posts: 28
Default Re: Inline PHP in HTML

I'm also new in php and I wanted to learn more. I saw some site that are .html extension but a it has a php code in it and that's what I want to find out.
ryanne is offline   Reply With Quote
Old 01-08-2010, 04:20 AM   #6 (permalink)
vanguard
Junior Member
 
Join Date: Jan 2010
Posts: 4
Default Re: Inline PHP in HTML

Thats a setting within a number of HTTP daemons like Apache and litespeed. You can set which file extensions are handled with which script parser (such as PHP). You can set any file extension to be parsed with PHP, ASP, CF etc.. which is why you sometimes see websites with non-standard file extensions such as .page. This effect can also be achieved with .htaccess files if you want to use this feature without access to the daemon config settings.
vanguard is offline   Reply With Quote
Old 01-19-2010, 10:10 PM   #7 (permalink)
Tharaka Deshan
Junior Member
 
Join Date: Jan 2010
Posts: 13
Default Re: Inline PHP in HTML

I am agree with vanguard, how you call a php function from a client side mouse over detecting from a server side script.
But you can do it by using a javascript to detect mouseover at client side and let that javascript to call a php function.It is possible to do so.
Tharaka Deshan is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View:
Points Per Thread:
Points Per Reply:



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 03:18 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums