Bobafart
07-14-2007, 03:27 AM
I have a JS var and I want to pass it to PHP for a mySQL select
function foo (boo){
<?php
$sql = "SELECT boogie FROM man where id = boo";
$result = mysql_query($sql);
?>
...
}
can boo be passed to PHP? and if so, how?
rafiki
07-14-2007, 03:40 AM
you could use window.location to add querystring to url and use $_GET['varname'];
simple :)
Bobafart
07-14-2007, 03:45 AM
you could use window.location to add querystring to url and use $_GET['varname'];
simple :)
there are no URLs here... this code is all in one script ...
I have a JS var which I pass into a function
I want to use that same var in PHP inside this function
StupidRalph
07-14-2007, 04:15 AM
If you're trying to use javascript to pass to some PHP on the same page "you can't" without reloading the same page. PHP (server-side) is finished parsing by the time javascript(client-side) comes into play.
However if you want to use PHP variable in javascript, you can just echo it out to the JS.
rafiki
07-14-2007, 12:04 PM
If you're trying to use javascript to pass to some PHP on the same page "you can't" without reloading the same page. PHP (server-side) is finished parsing by the time javascript(client-side) comes into play.
However if you want to use PHP variable in javascript, you can just echo it out to the JS.
hence the window.location post above :)