soleil_m
04-27-2006, 10:42 AM
Hello,
I've got a problem with my javascript function. I'd like to make sql query from it and pass its result back to function. What more I need to pass javascript variable to php select. Function must be in javascript bacause it's called by onchange event.
[Code]
function foo(my_var)
{
<?php
$MyVar = "?>document.write(my_var);<?php";
$MyVar = str_replace("?>", "", $MyVar2);
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('database');
$result = mysql_query("SELECT * FROM tableA WHERE id = $MyVar")
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$var2 = $row[0]."=".$row[1];
}
mysql_free_result($result);
echo $var2;
?>
}
Can I do sthg like that or is it totally wrong? How can I make it work?
Thanks in advance.
I've got a problem with my javascript function. I'd like to make sql query from it and pass its result back to function. What more I need to pass javascript variable to php select. Function must be in javascript bacause it's called by onchange event.
[Code]
function foo(my_var)
{
<?php
$MyVar = "?>document.write(my_var);<?php";
$MyVar = str_replace("?>", "", $MyVar2);
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('database');
$result = mysql_query("SELECT * FROM tableA WHERE id = $MyVar")
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$var2 = $row[0]."=".$row[1];
}
mysql_free_result($result);
echo $var2;
?>
}
Can I do sthg like that or is it totally wrong? How can I make it work?
Thanks in advance.