0

Im trying to pass a javascript value into PHP:

for(var i = 1; i <= 4; i++)
{
    var randomRuta = Math.floor((Math.random() * 100) + 1); 
    $('.click#'+randomRuta).addClass('monster').html($('<img src="blackdot.png" title="<?= $row['i'] ?> Level <?= $row['i'] ?>">'));
}

In this case, I is an javascript Value.

Here is my PHP:

mysql_connect($host,$user,$password)
    or die(mysql_error());
mysql_select_db($database)
    or die(mysql_error());
$monster = mysql_query("SELECT * FROM monster");

I want to assign the javascript variable into the PHP variable. Is this possible without involving Ajax?

4
  • 1
    in short - no its not, perhaps some reading on client side vs server side scripting... Commented Jun 3, 2014 at 12:01
  • 1
    No its not possible, php runs ONCE when the page is loaded Commented Jun 3, 2014 at 12:01
  • Take a look here stackoverflow.com/questions/419240/… Commented Jun 3, 2014 at 12:03
  • This is because you don't have a deep understanding about PHP and server-side and javascript and client side. You can have kind of relation between them using AJAX. Commented Jun 3, 2014 at 12:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.