how to apply css for the data fetched from the database
I am fetching the datas from the database...And the datas are displayed as dropdownmenu but the css is not applied
<ul id="nav">
<?php
$res=mysql_query("SELECT * FROM menu WHERE PARENT_ID=0");
while($row=mysql_fetch_array($res))
{
echo "<li class='top'><a href='#' class='top_link'>".$row['MENU_NAME']."</a></li>";
$res1=mysql_query("SELECT * FROM menu WHERE PARENT_ID=1 AND CHILD_ID=".$row['ID']."");
while($row1=mysql_fetch_array($res1))
{
echo "<ul class='sub'><li class='top'><a href='#' >".$row1['MENU_NAME']."</li></ul>";
$res2=mysql_query("SELECT * FROM menu WHERE PARENT_ID=2 AND CHILD_ID=".$row1['ID']."");
echo "<ul>";
while($row2=mysql_fetch_array($res2))
{
echo "<ul><li class='fly'><a href='#'>".$row2['MENU_NAME']."</li></ul>";
}
echo "</ul>";
}
echo "</ul>";
}
?>
</ul>
<h1> </h1>
<hr/>
this is my view page my datas must be arranged in such a order that datas in the class='top' must be arrrived as as the main menu the datas in the class="sub" must be arrivd as submenu the datas in the class="fly" must be arrived as sub menu to the submenu The format is ->main menu -> submenu1->submenu11 ->submenu12
-> submenu2 -> submenu3 when i give hard coded datas i am receiving in order that when i hover main menu submenu will be displayed .. the hard coded code is
Products- Nikon
when i hover submenu.. A submenu of the sub menu is be displayed I got these results How can apply the css to the datas fetchded from th database my whole view page is stu nicholls dot com | menu - Professional 开发者_StackOverflow社区dropdown #2
Products- Nikon
<ul id="nav">
<?php
$res=mysql_query("SELECT * FROM menu WHERE PARENT_ID=0");
while($row=mysql_fetch_array($res))
{
echo "<li class='top'><a href='#' class='top_link'>".$row['MENU_NAME']."</a></li>";
$res1=mysql_query("SELECT * FROM menu WHERE PARENT_ID=1 AND CHILD_ID=".$row['ID']."");
while($row1=mysql_fetch_array($res1))
{
echo "<ul class='sub'><li class='top'><a href='#' >".$row1['MENU_NAME']."</li></ul>";
$res2=mysql_query("SELECT * FROM menu WHERE PARENT_ID=2 AND CHILD_ID=".$row1['ID']."");
echo "<ul>";
while($row2=mysql_fetch_array($res2))
{
echo "<ul><li class='fly'><a href='#'>".$row2['MENU_NAME']."</li></ul>";
}
echo "</ul>";
}
echo "</ul>";
}
?>
</ul>
<h1> </h1>
<hr/>
Can anyone give me suggestion
Not directly a solution for your problem but why are you using a framework such as CI, which works around the MVC-principle and in the meantime have PHP and SQL statements in your view?
I suggest you read up on these CI topics:
- Template parser: https://www.codeigniter.com/userguide2/libraries/parser.html
- Database (active record): https://www.codeigniter.com/userguide2/database/active_record.html
- Views: https://www.codeigniter.com/userguide2/general/views.html
What's the CSS you're currently using?
精彩评论