How can i assign a javascript variable to php variable
Posted: Tue Jan 06, 2009 1:21 am
hello everybody
I need to assign the value of js variable to php variable when js for loop works...my code look like this
<script langauge="javascript" type="text/javascript">
/* there is an array with values let it be */
var dataArray = array("1","2","3")
for(i = 0;i < dataArray.length;i++)
{
/* Here i need to assign the js variable to php variable so that i can use it in a query. I tried the following script*/
<?php $i = ?> dataArray
<?php
$query = "SELECT * FROM tablename WHERE field = '$i'";
//code continues....
?>
</script>
But i am getting error....
Please help me to find out the solution....please......
I need to assign the value of js variable to php variable when js for loop works...my code look like this
<script langauge="javascript" type="text/javascript">
/* there is an array with values let it be */
var dataArray = array("1","2","3")
for(i = 0;i < dataArray.length;i++)
{
/* Here i need to assign the js variable to php variable so that i can use it in a query. I tried the following script*/
<?php $i = ?> dataArray
<?php
$query = "SELECT * FROM tablename WHERE field = '$i'";
//code continues....
?>
</script>
But i am getting error....
Please help me to find out the solution....please......