我有这段代码不起作用
<body>
<?php $outerSql = mysql_query("select * from gree_menu"); ?>
<ul>
<?php
while($outerRow = mysql_fetch_array($outerSql)) {
$outerMenu = $outerRow['menu_name'];
$outerId = $outerRow['menu_id'];
?>
<li>
<?=$outerMenu; ?>
<?php $innerSql = mysql_query("SELECT sp.* FROM gree_menu gm INNER JOIN silicon_prod sp ON gm.menu_id = sp.menu_parent_id WHERE gm.menu_id = {$outerID}");?>
<ul>
<?php
while($innerRow = mysql_fetch_array($innerSql)) {
$innerMenu = $innerRow['prod_name'];
?>
<li><?= $innerMenu;?></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
给我带来麻烦的线路是
<?php $innerSql = mysql_query("SELECT sp.* FROM gree_menu gm INNER JOIN silicon_prod sp ON gm.menu_id = sp.menu_parent_id WHERE gm.menu_id = {$outerID}");?>
如果我将查询作为
<?php $innerSql = mysql_query("SELECT sp.* FROM gree_menu gm INNER JOIN silicon_prod sp ON gm.menu_id = sp.menu_parent_id WHERE gm.menu_id = 7");?>
它工作正常。但我希望它是动态的。menu_id 的有效值为 7、8、9
请帮忙