Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default Problems with javascript, pfft!

    right i searched google and i can't find ANYTHING that is easy enough for me to understand. I can do php but NOT javascript.

    How would i go about setting a php variable as a js object or setting a php session as a js object or w/e

    Eg.

    PHP Code:
    <?
    $playername 
    JAVAVARHERE ?>
    My current code is:

    HTML Code:
    <script type=text/javascript>
    function addplayer(id){
    ");
    $xyz = mysql_query("SELECT * FROM `players` WHERE `id`='id'");
    $xyzz = mysql_fetch_array($xyz);
    echo ("
    alert('You have selected'+id);
    alert('$xyzz[lastname]');
    }
    </script>
    And obv my query is duffage. +rep to all help

  2. #2
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    You can't. Just echo the data directly into the javascript code.

  3. #3
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    <?php
    include "config.php"; // includes config file

    $query = mysql_query("SELECT * FROM table");
    $row = mysql_fetch_array($query);
    ?>
    <script type="text/javascript">
    alert('<?=$row[thingy];?>');
    </script>

    One way to do it.

Posting Permissions

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