我的 javascript 数组有问题。咆哮我的代码:
$namen = array();
$mainimg = array();
$sql1 = mysql_query("SELECT * FROM image WHERE id = ".$id.";");
echo "<div class='normal'>";
while($row = mysql_fetch_array($sql1))
{
$namen[] = $row['bild'];
$mainimg[] = $row['mainimg'];
$number_array = count($namen);
?>
<script type='text/javascript'>
<?php
for($a=1; $a <= count($namen); $a++){
$php_array = array($a => $row['bild']);
$js_array = json_encode($php_array);
echo "var javascript_array = ". $js_array . ";\n";
echo "document.write(javascript_array + '<br />');";
}
?>
</script>
}
现在我在浏览器中得到 [object][Object],但我想打印出元素,图片的名称。我能做些什么?
提前感谢您的帮助。
问候, 亚尼克