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?

user500468
  • 1,183
  • 6
  • 21
  • 36
  • 1
    in short - no its not, perhaps some reading on client side vs server side scripting... – RaggaMuffin-420 Jun 03 '14 at 12:01
  • 1
    No its not possible, php runs ONCE when the page is loaded – Steve Jun 03 '14 at 12:01
  • Take a look here http://stackoverflow.com/questions/419240/how-to-get-javascript-function-data-into-a-php-variable – Bart Burg Jun 03 '14 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. – Sina R. Jun 03 '14 at 12:04

0 Answers0