Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Unanswered: Use php in javascript

    Hi,

    I know it's not smart to use php and javascript together, but i need it. So I would like to know if this is possible.

    I have a php code to get my records from my database. And then I have a Javascript to make a tree structure (like windows). I need to be able to use my php variables in my javascript so that my tree structure can ben dynamic.

    Is this possible and does somebody know how to do this?
    Tanks in advance

    Berkowitz

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    dunno where you got this idea from
    I know it's not smart to use php and javascript together, but i need it. So I would like to know if this is possible.
    There is no problem in using Javascript and PHP, PHP can provide the server side scripting, Javascript can provide a better user interaction. It goes by numerous names, but it can be used in Web2 or AJAX.
    you cannot run any PHP variable at the client.. by defintion the server renders the PHP script and transmits it to the client. In a web app that means the output is usually HTML (fragments or whole pages).

    Hwoever you can output the values jn the PHP script in Javascript.

    I'd suggest do some googling on AJAX and Web 2 in the php environemnt

    Hpowever I would say debugging an AJAX / web 2 app can be a real pain unless you have the right tools

  3. #3
    Join Date
    Mar 2008
    Posts
    11
    Quote Originally Posted by Berkowitz
    Hi,

    I know it's not smart to use php and javascript together, but i need it. So I would like to know if this is possible.

    I have a php code to get my records from my database. And then I have a Javascript to make a tree structure (like windows). I need to be able to use my php variables in my javascript so that my tree structure can ben dynamic.

    Is this possible and does somebody know how to do this?
    Tanks in advance

    Berkowitz
    Yes, you can use your php variables in javascript. Of course, you j ust have to enclose it in php tags:
    Code:
    <?=$yourvariable?>
    Website Hacks
    Programming/computer help

  4. #4
    Join Date
    Jul 2007
    Location
    Africa
    Posts
    7
    it all boils down to what you wanna archive

Posting Permissions

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