GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Jun-2017, 13:15
DionLieb DionLieb is offline
New Member
 
Join Date: Jun 2017
Posts: 2
DionLieb is on a distinguished road

Need some help with css..


Hi I have a php code running which collects data from two tables and supplies the results to a <ul><li> list for a dynamic vertical menu
the php code will be run through Ajax request when testing is done
but I have run into a issue as the php code runs fine but as soon as I add the css properties to the page the sub menu list only shows the first sub menu and nothing after that but without the css it shows all the sub menus from the database could anyone help with the code please.

css code
_________________________________________________
<style>
*{
padding:0;
margin: 0;
}
a{
text-decoration: none;
}
li{
list-style: none;
}
.main-nav{
width: 400px;
background-color:rgba(100,205,203,1.00);

}
.main-nav a{
text-transform:uppercase;
letter-spacing: .2em;
display: block;
padding: 10px 0 10px 20px;
color: white;
border-bottom: 1px dotted grey;
}
.main-nav a:hover{
background-color: rgba(121,165,167,1.00);
}
.main-nav-ul ul{
display: none;
}
.main-nav-ul li:hover ul{
display: block;
padding-left: 20px;
}
</style>
-----------------------------------------------------------------
php code------------------------------
<?php
include "../../the_database/connect_db.php";
echo "<nav class='main-nav'>";
echo "<ul class='main-nav-ul'>";
$menu_query = "SELECT * FROM admin_menu";
$run_query = mysqli_query($con,$menu_query);
if(mysqli_num_rows($run_query) > 0){

while($row = mysqli_fetch_array($run_query)){
$m_id = $row["amenu_id"];
$m_name = $row["amenu_name"];
echo"<li ><a href='#'>$m_name</a>";
$sub_query = "SELECT * FROM asub_menu where parent_id = '$m_id'";
$run_query2 = mysqli_query($con,$sub_query);
if(mysqli_num_rows($run_query2) > 0){
while($row2 = mysqli_fetch_array($run_query2)){
$sub_name = $row2['asub_name'];
echo "<ul class='secondUl'>";
echo "<li id='secondli'>";
echo "<a href='#'>$sub_name</a>";
echo "</li>";
echo "</ul>";
echo "</li>";
}
}

}
echo "</ul>";
}
echo'</nav>'
?>
_______________________________________________
Attached Images
File Type: png withoutcss.png (6.7 KB, 8 views)
File Type: png withcss.png (10.0 KB, 9 views)
  #2  
Old 01-Jun-2017, 17:00
DionLieb DionLieb is offline
New Member
 
Join Date: Jun 2017
Posts: 2
DionLieb is on a distinguished road

Re: Need some help with css..


changed the php code and all seems to be working.
--------------------------------------------------------
<?php
include "../../the_database/connect_db.php";
echo "<nav class='main-nav'>";
echo "<ul class='main-nav-ul'>";
$menu_query = "SELECT * FROM admin_menu";
$run_query = mysqli_query($con,$menu_query);
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$m_id = $row["amenu_id"];
$m_name = $row["amenu_name"];
echo"<li class='has-sub' ><a href='#'>$m_name<span class='sub-arrow'></span></a>";
$sub_query = "SELECT * FROM asub_menu where parent_id = '$m_id'";
$run_query2 = mysqli_query($con,$sub_query);
if(mysqli_num_rows($run_query2) > 0){
while($row2 = mysqli_fetch_array($run_query2)){
$sub_name = $row2['asub_name'];
echo "<ul>";
echo "<li>";
echo "<a href='#'>$sub_name</a>";
echo "</li>";
echo "</ul>";
}

echo "</li>";
}
}
echo "</ul>";
}
echo'</nav>'
?>
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:33.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.