我想在 javascript 中传递 php 值。我在 javascript 上运行查询并应用 if 语句和 while 数组。但总是显示空结果。我找不到问题。任何人请帮助我。谢谢
<?php
session_start();
$SUserName=$_SESSION['view'];
include 'dbconnect.php';
$query="select * from user_permission where username='$SUserName'";
$result=mysql_query($query) or die (mysql_error());
?>
<script type="text/javascript">
d = new dTree('d');
d.add(0,-1,'Dhuronto');
<?php
if($SUserName=='sumon@dhuronto.com')
{
echo "d.add(1,0,'Admin','blank.php', 'Admin', 'main');";
}
else {
while ($row = mysql_fetch_array($result))
{
echo "d.add('$id','$pid','$node','$url', '$node', 'main');";
}
}
?>
</script>