I have this code which is not working
<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>
The line that is causing me trouble is
<?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}");?>
If i give the query as
<?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");?>
it works fine. But i want it to be dynamic. Valid values for menu_id are 7, 8, 9
Please help
outerID, notouterId. PHP is case sensitive. I recommend using copy/paste for variable names, or using a text editor that has autocomplete (try out Sublime Text or Eclipse). Using either copy/paste or autocomplete will save you time and frustration by reducing typos like this one.