Hi,
I want to transfer the data from php to a js array. I have a query and need to copy it to a js array. Here is the code i've made and it doesn't work. Maybe someone can tell me what's wrong cause i'm not too sure yet how php works with js. Thanks alot.
Here is the code:
<html>
<head>
<title></title>
<script language="javascript">
<!--
var i;
countries=new Array();
cities=new Array();
//-->
</script>
</head>
<body>
<?php
include("conectare_db.php");
//array tari indexate dupa id tara//
$sql="select * from tari";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
?>
<script language="javascript">
<!--
for(i=0;i<countries.length;i++)
countries='<?echo "$row['nume_tara']"?>';
<?php
}
?>
for(i=0;i<countries.length;i++)
document.writeln("Tara"+countries[0]);
//-->
</script>
</body>
</html>