SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink Adding Javascript in PHP

    Hi Can someone help me please?
    I have this code in a php file (it's called rotator.php):
    <?
    require("/path/to/server/phpadmentor_config.php")
    ?>
    <?
    {
    echo(PhpAdMentor_GetAd("7", 5, 13) );
    }
    ?>
    ..and it woks Just Fine!
    ..now the thing is that I want to call it with:
    <script language="javascript" src="<A href='http://www.mysite.com/rotator.php">http://www.mysite.com/rotator.php"></script>
    ..from a HTML document.
    However, I don't know how to add the Javascript in the PHP file:
    This is my guess, but it wont work
    <?
    require("/path/to/server/phpadmentor_config.php")
    ?>
    <?
    $action="js";
    if ($action=="js")
    {
    echo(PhpAdMentor_GetAd("7", 5, 13) );
    }
    ?>

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try...

    PHP Code:
    $action="js";
    if (
    $action=="js" ) {
      echo(
    "document.write('".PhpAdMentor_GetAd("7"513)."')");

    Just out of curosity why do you have an integer as a string?

  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You do not need to INCLUDE nor REQUIRE to execute I wouldn't think.

    The PHP side of things will be parsed by the server provided the file has the PHP extension, though the Javascript will be executed by the browser client-side provided the Javascript has no errors.

    To execute the actual function you just place the <script language='javascript1.2' src="filename.php"></script> where ever on the page you'd want the advert 8)

    I think this is what your asking ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •