Help with Javascript in php

This is a discussion on "Help with Javascript in php" within the PHP Forum section. This forum, and the thread "Help with Javascript in php are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 25th, 2006, 00:29
Junior Member
Join Date: Sep 2006
Location: London
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Help with Javascript in php

Hi everyone here has been very hepful in the past I was wondering if anyone could take a look at this code for me I am findiong php very difficult. I have created a flash menu with some software and I am trying to input this into my header script. This is the code I have

<?php $thisfile = "header.php";if(SHOWFILENAMES == "on"){echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";}?>
<!-- start of header.php -->
<script type="text/javascript" src="flashobject.js"></script>
<table bgcolor="white">


<tr>
<img src="<?php echo INSTALLPATH;?>images/header.jpg" width="780" height="175" border=0 alt="<?php echo IMPLEMENTATION_NAME;?>">

</td>
</tr>


<tr>
<td>
<!-- table for icons - start -->
<div id="color_id" >123 Flash Menu Placeholder.</div>
<script type="text/javascript">
var fo = new FlashObject("/images/menu.swf", "color", "780", "244", "6", "#FFFFFF");
fo.addParam("menu","false");
fo.addParam("quality","best");
fo.addParam("salign","LT");
fo.addParam("scale","noscale");
fo.addParam("wmode", "transparent");
fo.write("color_id");
</script>
<!-- table for icons - end -->
</td>
</tr>
</table>
<!-- end of header.php -->

The softwre I have used has created a .swf file and a JScript Script File I have placed the swf in my images folder but I am unsure where to put the jscript file. If anybody could help me resolve this it would be fantastic.
Please don't be to harsh if it is a very stupid mistake I am still a noob.

Cheers
Reply With Quote

  #2 (permalink)  
Old Oct 25th, 2006, 10:38
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Help with Javascript in php

Quote:
Originally Posted by Martin McPherson View Post
<?php $thisfile = "header.php";if(SHOWFILENAMES == "on"){echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";}?>
<!-- start of header.php -->
<script type="text/javascript" src="flashobject.js"></script>
<table bgcolor="white">


<tr>
<img src="<?php echo INSTALLPATH;?>images/header.jpg" width="780" height="175" border=0 alt="<?php echo IMPLEMENTATION_NAME;?>">

</td>
</tr>


<tr>
<td>
<!-- table for icons - start -->
<div id="color_id" >123 Flash Menu Placeholder.</div>
<script type="text/javascript">
var fo = new FlashObject("/images/menu.swf", "color", "780", "244", "6", "#FFFFFF");
fo.addParam("menu","false");
fo.addParam("quality","best");
fo.addParam("salign","LT");
fo.addParam("scale","noscale");
fo.addParam("wmode", "transparent");
fo.write("color_id");
</script>
<!-- table for icons - end -->
</td>
</tr>
</table>
<!-- end of header.php -->
This looks very confused code. Is this meant to be a file in its own right or included as part of another/other files?

Note the bit of code I have highlighted above. This closing tag has no matching opening tag.
Reply With Quote
  #3 (permalink)  
Old Oct 25th, 2006, 12:55
Junior Member
Join Date: Sep 2006
Location: London
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help with Javascript in php

Hi mate thanks for replying and yuor help before. I have realised php is not my strong suite. I am not suprised that the code is confused I am struggling with php. I have decided to work with htm in the large part as this is what I know. This is one of the last things I need to do with my php scripts. This is a template page which I include at the top of each of m php pages.

Example

<?php include_once("templates/header.php");?>

I am now only looking at using a small amount of php pages for my site and I am finally getting somewhere with it. Do you have any idea how i could clean this code up.

I have been studying php but i really want to get my site up and running. I think it will take me a while longer to get my head round php. Again if you could help it would be much appreciated.

Cheers
Reply With Quote
  #4 (permalink)  
Old Oct 27th, 2006, 11:47
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help with Javascript in php

Hey Martin.

I'm a little confused by this, because it's called "header" but there isn't any html markup. Don't you want the initial javascript reference in the <head>? Maybe not, this really just looks like a table you want to insert at some point.

Hmm, I'm thinking maybe you want this include in the body but can't figure out how to get the javascript reference in the <head> section? If so, you need to echo a variable $showtable in the <head> section of the page.
Code: Select all
<html><head><?php echo $showtable; ?> . . . </head>
Then set the variable in the include file, like
Code: Select all
$showtable = '<script type="text/javascript" src="flashobject.js"></script>';
The only kicker is that the include will have to occur higher on the page than the <head> so that the variable is defined before it is echoed.

I can't comment on the functionality of the code, but I have a couple of technique hints. There's nothing wrong with what you have, I just thought you might want to see a couple of other ways to do it.
Code: Select all
{echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";}
First off, you don't need the curly brackets if you only have one result from an "if" condition.i
Code: Select all
if(SHOWFILENAMES == "on") echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";
If you use php to echo html markup, the "heredoc" statement is handy for long passages. What you already have might be better but I just thought I'd show it to you if you don't know about it.
Code: Select all
if (SHOWFILENAMES == "on")
 $s= <<<EOD
<p class="filename">This file is: $thisfile</p>
EOD
echo $s;
No markup, no escapes, no concats.

Once you bother doing all the escaping work to have a passage in double quotes, there's no need to worry about concats (and vice versa). You're doing double effort.
Either
Code: Select all
echo '<p class="filename">This file is: ' . $thisfile . '</p>';
or
Code: Select all
echo "<p class=\"filename\">This file is: $thisfile</p>";
Like you, I'm learning php. I've been studying a little every day, for a few months. It's like the Hydra: everytime you cut off one head, two grow back. It's been a big help to me to do nothing but study for a bit every day. Currently I'm working my way through O'Reilly's "Programming PHP" and a really good (free!) online tutorial about regular expressions at http://www.regular-expressions.info/php.html

I hope these hints are helpful (and correct, LOL).
Reply With Quote
Reply

Tags
javascript, php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
php and javascript yvettesio JavaScript Forum 8 Mar 14th, 2007 23:18
JavaScript cbrams9 JavaScript Forum 1 Sep 20th, 2006 17:35
using xml in javascript shailu JavaScript Forum 0 Jul 25th, 2006 07:36
Can someone help me with this javascript Galaxyblue JavaScript Forum 2 Mar 11th, 2004 12:18
what does \\ mean in javascript jenjen1018 JavaScript Forum 5 Jan 6th, 2004 17:05


All times are GMT. The time now is 08:13.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43