Whenever somebody says "dynamic variables" it's a big red flag. You can do them but it's a bad idea 99% of the time. What you're probably looking for is an array. If you write:
$menus = array();while($parent_row = mysql_fetch_array($parent_result)){ $menus[$i] = "\n\t$('#menu_" . $i . "').hover(function () {";}echo $menus[1];echo $menus[2];echo $menus[3];
You'll get what you're after without delving into the maintenance headache & potential disaster that dynamic variable names would give you. You can also easily loop over $menus
which makes things nice when you suddenly have 2, 4 or 40 different elements.