header hover problem any one have solution? - php

<?php
$q = $pdo->prepare("SELECT * FROM tbl_menu WHERE menu_parent=? ORDER BY menu_order ASC");
$q->execute(array(0));
$res = $q->fetchAll();
foreach ($res as $row) {
$r = $pdo->prepare("SELECT * FROM tbl_menu WHERE menu_parent=?");
$r->execute(array($row['menu_id']));
$total = $r->rowCount();
echo ' <li class="header_nav-list_item dropdown">';
if($row['page_id'] == 0) {
if($row['menu_url'] == '') {
$final_url = 'javascript:void(0);';
} else {
$final_url = $row['menu_url'];
}
?>
<a class="nav-link nav-item dropdown-toggle d-inline-flex align-items-center"
href="<?php echo $final_url; ?>"><?php echo $row['menu_name']; ?><?php if($total) {echo ' <i class="icon-angle-down icon"></i>';}; ?></a>
<?php
} else {
$r = $pdo->prepare("SELECT * FROM tbl_page WHERE page_id=? ");
$r->execute(array($row['page_id']));
$res1 = $r->fetchAll();
foreach ($res1 as $row1) {
?>
<a class="nav-link nav-item dropdown-toggle d-inline-flex align-items-center"
data-bs-toggle="collapse"
data-bs-target="#Menu"
data-trigger="dropdown"
aria-expanded="false"
aria-controls="Menu"
data-page="" href="<?php echo BASE_URL.URL_PAGE.$row1['page_slug']; ?>"><?php echo $row1['page_name']; ?>
<?php if($total) {echo '<em></em>';}; ?></a>
<?php
}
}
// Checking for sub-menu
$r = $pdo->prepare("SELECT * FROM tbl_menu WHERE menu_parent=?");
$r->execute(array($row['menu_id']));
$total = $r->rowCount();
if($total) {
echo ' <div class="dropdown-menu collapse"><ul>';
$res1 = $r->fetchAll();
foreach ($res1 as $row1) {
//
echo '<li class="dropdown-list">';
if($row1['page_id'] == 0) {
if($row1['menu_url'] == '') {
$final_url1 = 'javascript:void(0);';
} else {
$final_url1 = $row1['menu_url'];
}
?>
<a class="dropdown-item nav-item" href="<?php echo $final_url1; ?>"><?php echo $row1['menu_name']; ?></a>
<?php
} else {
$s = $pdo->prepare("SELECT * FROM tbl_page WHERE page_id=?");
$s->execute(array($row1['page_id']));
$res2 = $s->fetchAll();
foreach ($res2 as $row2) {
?>
<a class="dropdown-item nav-item" href="<?php echo BASE_URL.URL_PAGE.$row2['page_slug']; ?>"><?php echo $row2['page_name']; ?></a>
<?php
}
}
echo '</li>';
//
}
echo '</ul></div>';
}
echo '</li>';
}
?>
This is my header code can any one tell me or updATE THIS CODE FOR ME
I WANT TO SOLVE MY PROBLEM

Related

How to set first menu active in mega menu?

I am trying to create a hoverable mega menu, all works fine except the active one.
I checked in source codes and active class is added, but it doesn't show up the content until mouseenter on it.
see image please :
And this is when I go on it with mouse, it show up with no problem.
I gues I need to set main (FINANCE is main menu in pic) menu active, but dont know how to pass it to submenu.
Here is my full code :
$stmt_menu = $pdo->prepare("SELECT * FROM categories WHERE parentId = ? LIMIT 5");
$stmt_menu->execute([0]);
if ($stmt_menu->rowCount() > 0) {
$query = $stmt_menu->fetchAll();
foreach ($query as $row) {
if ($row['cat_type'] == 'mega') {
?>
<li class="dropdown megamenu-fw mega-li-<?php echo $row['catId']; ?>">
<?php echo $row['catName']; ?><span class="caret"></span>
<ul class="dropdown-menu megamenu-content dropdown-top" role="menu" aria-expanded="true" data-mega-ul="<?php echo $row['catId']; ?>">
<li>
<?php
$stmt_menu = $pdo->prepare("SELECT * FROM categories WHERE parentId = ? LIMIT 5");
$stmt_menu->execute([$row['catId']]);
if ($stmt_menu->rowCount() > 0) {
$subquery = $stmt_menu->fetchAll();
?>
<div class="sub-menu-left">
<ul class="nav-sub-categories">
<?php
$i = 0;
foreach ($subquery as $subq) {
$actives = '';
if($i == 0){
$actives = ' active';
}
?>
<li data-category-filter="<?php echo $subq['cat_seo_url']; ?>-<?php echo $subq['catId']; ?>" class="li-sub-category<?php echo $actives; ?>"><?php echo $subq['catName']; ?></li>
<?php
$i++;
}
?>
</ul>
</div>
<div class="sub-menu-right">
<?php
$i = 0;
foreach ($subquery as $subcats) {
$actives = '';
if($i == 0){
$actives = ' active';
}
?>
<div class="sub-menu-inner filter-<?php echo $subcats['cat_seo_url']; ?>-<?php echo $subcats['catId']; ?><?php echo $actives; ?>">
<div class="row row-menu-right">
<div class="col-sm-3 menu-post-item">
<div class="post-item-image">
<a href="is-allowance-instantly-strangers-applauded">
<img src="assets/img/img_bg_md.png" data-src="uploads/images/202203/image_380x226_624239afd7295.jpg" alt="Is allowance instantly strangers applauded" class="lazyload img-responsive img-post" width="1" height="1"/>
</a>
</div>
<h3 class="title"><?php echo $subcats['cat_seo_url']; ?> Is allowance instantly strangers applauded</h3>
<p class="post-meta">
admin
<span>Mar 28, 2022</span>
<span><i class="icon-comment"></i>2</span>
<span class="m-r-0"><i class="icon-eye"></i>894</span>
</p>
</div>
</div>
</div>
<?php
$i++;
}
?>
</div>
<?php
}
?>
</li>
</ul>
</li>
<?php
} elseif ($row['cat_type'] == 'dropdown') {
echo ' <li class="nav-item"><a class="nav-link" href="' . $row["cat_seo_url"] . '">test</a></li>';
} else {
echo ' <li class="nav-item"><a class="nav-link" href="' . $row["cat_seo_url"] . '">' . $row["catName"] . '</a></li>';
}
}
}

Echoing html if data from SQL if statement true

So I've been struggling at how to echo this set of HTML with users that are set as admin from my database. I've looked at quite a few places for information but I'm struggling to get it to work. Perhaps I'm doing something really stupid. Thanks for your help.
<?php
$steamidb =&$steamprofile['steamid'];
$steamhextoid=dechex($steamidb);
$steamstart = 'steam:';
$steamhextoidfin = $steamstart . '' . $steamhextoid;
$sql = "SELECT group FROM users WHERE identifier='".$steamhextoidfin."'";
$result = $conn->query($sql);
if ($result->num_rows > 0)
// output data of each row
while($row = mysql_fetch_assoc($result))
{
if($row['group'] == 'admin')
{
echo '<li class="sub-menu">
<a href="javascript:;" >
<i class="fa fa-cogs"></i>
<span>Admin</span>
</a>
<!--<ul class="sub">
<li>COMING SOON</li>
<li>Buttons</li>
<li>Panels</li>
</ul>-->
</li>';
}
else {
echo "Error";
}
}
?>
I think that you forgot to put the while between {}. Here is the correct code:
<?php
$steamidb =&$steamprofile['steamid'];
$steamhextoid=dechex($steamidb);
$steamstart = 'steam:';
$steamhextoidfin = $steamstart . '' . $steamhextoid;
$sql = "SELECT group FROM users WHERE identifier='".$steamhextoidfin."'";
$result = $conn->query($sql);
if ($result->num_rows > 0){
// output data of each row
while($row = mysql_fetch_assoc($result))
{
if($row['group'] == 'admin')
{
echo '<li class="sub-menu">
<a href="javascript:;" >
<i class="fa fa-cogs"></i>
<span>Admin</span>
</a>
<!--<ul class="sub">
<li>COMING SOON</li>
<li>Buttons</li>
<li>Panels</li>
</ul>-->
</li>';
}
else {
echo "Error";
}
}
}
?>

How to add active class in dynamic menu list in codeigniter?

I want to display <li class = "active"> in my current URL when I click any menu.
Here is what I have tried:
<?php
$uri_string = $this->uri->uri_string();
$id_user = $usr->id;
$get_group = $this->db->get_where('users_groups', array('user_id'=> $id_user));
$hasil = $get_group->result();
foreach($hasil as $h)
if(isset($h->group_id)){
$in_group = $this->ion_auth->in_group($h->group_id);
if(isset($in_group)){
$get_menu = $this->db->get_where('menu',array('parent_menu' => 0, 'menu_users_groups' => $h->group_id));
$menu = $get_menu->result();
foreach($menu as $m){
$cekSub = $this->db->get_where('menu',array('parent_menu' => $m->id));
if($cekSub->num_rows() > 0){
echo '<li>';
echo '
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">'.$m->icon.'</i> <span>'.$m->menu_name.'</span>
</a>
<ul class="ml-menu">
<li>';
foreach($cekSub->result() as $c)
echo anchor(''.$c->controller_link.'','<i class="material-icons">'.$c->icon.'</i><span> '.$c->menu_name.'</span>');
echo '</li>
</ul>
</li>';
} else {
echo '<li>';
echo anchor(''.$m->controller_link.'','<i class="material-icons">'.$m->icon.'</i><span> '.$m->menu_name.'</span>');
echo '</li>';
}
}
}
}
?>
The problem is, that if not in the curent URL class, active is hidden - just <li> is displayed.
How to fix this?
it's solved with :
<?php
$getUri = $this->uri->uri_string();
$id_user = $usr->id;
$get_group = $this->db->get_where('users_groups', array('user_id'=> $id_user));
$hasil = $get_group->result();
foreach($hasil as $h)
if(isset($h->group_id)){
$in_group = $this->ion_auth->in_group($h->group_id);
if(isset($in_group)){
$get_menu = $this->db->get_where('menu',array('parent_menu' => 0, 'menu_users_groups' => $h->group_id));
$menu = $get_menu->result();
foreach($menu as $m){
$cekSub = $this->db->get_where('menu',array('parent_menu' => $m->id));
$getSub = $cekSub->result();
if($cekSub->num_rows() > 0){
echo '<li';
foreach($getSub as $c)
if($c->controller_link==$getUri){echo ' class="active"';}
echo '>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">'.$m->icon.'</i> <span>'.$m->menu_name.'</span>
</a>
<ul class="ml-menu">
<li>';
foreach($getSub as $c)
echo anchor(''.$c->controller_link.'','<i class="material-icons">'.$c->icon.'</i><span> '.$c->menu_name.'</span>');
echo '</li>
</ul>
</li>';
} else {
echo '<li';
if($m->controller_link==$getUri){echo ' class="active"';}
echo '>';
echo anchor(''.$m->controller_link.'','<i class="material-icons">'.$m->icon.'</i><span> '.$m->menu_name.'</span>');
echo '</li>';
}
}
}
}
?>

smart PHP Pagination

I want to split pages to make it more smart and look nice,
I use this code to make Pagination
if (!isset($_GET['page'])){
$page = 1;
}
else {
$page = intval($_GET['page']);
}
$numbershownews = 1;
$x = ($page-1)*$numbershownews;
$select_news_all = $mysqli->query("SELECT id FROM news where FIND_IN_SET('$id_newscats_cat', cats) order by time desc");
$num_news_all = $select_news_all->num_rows;
$cn = $num_news_all/$numbershownews;
$select_news = $mysqli->query("SELECT * FROM news where FIND_IN_SET('$id_newscats_cat', cats) order by time desc limit $x,$numbershownews");
while ($rows_news = $select_news->fetch_array(MYSQL_ASSOC)){
$id_news = $rows_news ['id'];
$title_news = $rows_news ['title'];
}
i show pages by this code
<?
$pagenext = $page+1;
$pageprev = $page-1;
?>
<ul>
<li>
<?
if (($page == 1) or ($page == "")){
?>
<i class="fa fa-angle-double-right"></i>
<?
}else{
?>
<a class="link" href="<? echo "{$newurltitle_newscats_cat}-c-{$id_newscats_cat}-p-{$pageprev}.html"; ?>"><i class="fa fa-angle-double-right"></i></a>
<?
}
?>
</li>
<?php
for($i=0; $i<$cn; $i++){
$pagenumber = $i+1;
if($page == $pagenumber){
echo "<li>{$pagenumber}</li>";
}else{
?>
<li><a class="link" href="<? echo "{$newurltitle_newscats_cat}-c-{$id_newscats_cat}-p-{$pagenumber}.html"; ?>"><? echo $pagenumber; ?></a></li>
<?
}
}
?>
<li>
<?
if($page >= $cn){
?>
<i class="fa fa-angle-double-left"></i>
<?
}else{
?>
<a class="link" href="<? echo "{$newurltitle_newscats_cat}-c-{$id_newscats_cat}-p-{$pagenext}.html"; ?>"><i class="fa fa-angle-double-left"></i></a>
<?
}
?>
it works well but it gives me pages like this 1,2,3,4,5,6,7,8,9,10 i want to split pages like this 1,2,3,4,...,9,10 how can i do this
thanks

Menu Items Not Closing?

I'm coding a staff panel but I'm stuck I've added a menu (navigation) but I'm stuck on how to go about opening it when clicked and closing it when clicked if open.
Here is the code i have so far;
<ul id="menu" class="nav">
<?php
$url = $_GET['url'] ? $core->clean($_GET['url']) : 'core.home';
$query3 = $db->query("SELECT * FROM menu WHERE url = '{$url}'");
$array3 = $db->assoc($query3);
if (!$array3['usergroup']) {
$array3['usergroup'] = "invalid";
}
$query = $db->query("SELECT * FROM usergroups ORDER BY weight ASC");
while ($array = $db->assoc($query)) {
if (in_array($array['id'], $user->data['uGroupArray'])) {
?>
<div class="menustyle" onclick="Radi.menuToggle('<?php echo $array['id']; ?>');">
<div class="menutext"><?php echo $array['name']; ?></div>
</div>
<ul>
<li class="menuitems"<?php if ($array['id'] != $array3['usergroup']) { ?> onclick="Radi.menuToggle('<?php echo $array['id']; ?>');" style="display: none;"<?php } ?> id="mitems_<?php echo $array['id']; ?>">
<?php
$query2 = $db->query("SELECT * FROM menu WHERE usergroup = '{$array['id']}' AND visible = '1' ORDER BY weight ASC");
$i = "a";
while ($array2 = $db->assoc($query2)) {
?>
<li>
<?php echo $array2['text']; ?>
</li>
<?php
$i++;
if ($i == "c") {
$i = "a";
}
}
?>
</ul>
</li>
<?php
}
}
?>
</li>
</ul>
</div>
And this is the defualt code when you download radipanel;
<div style="float: left; width: 200px;">
<?php
$url = $_GET['url'] ? $core->clean($_GET['url']) : 'core.home';
$query3 = $db->query("SELECT * FROM menu WHERE url = '{$url}'");
$array3 = $db->assoc($query3);
if (!$array3['usergroup']) {
$array3['usergroup'] = "invalid";
}
$query = $db->query("SELECT * FROM usergroups ORDER BY weight ASC");
while ($array = $db->assoc($query)) {
if (in_array($array['id'], $user->data['uGroupArray'])) {
?>
<div class="box">
<div class="square menu" style="background: #<?php echo $array['colour']; ?>;" onclick="Radi.menuToggle('<?php echo $array['id']; ?>');">
<img id="menutoggle_<?php echo $array['id']; ?>" class="menutoggle" src="_img/<?php echo ( $array['id'] != $array3['usergroup'] ) ? 'plus' : 'minus'; ?>_white.png" alt="Toggle" align="right" />
<strong><?php echo $array['name']; ?></strong>
</div>
<div class="menuitems"<?php if ($array['id'] != $array3['usergroup']) { ?> style="display: none;"<?php } ?> id="mitems_<?php echo $array['id']; ?>">
<?php
$query2 = $db->query("SELECT * FROM menu WHERE usergroup = '{$array['id']}' ORDER BY weight ASC");
$i = "a";
while ($array2 = $db->assoc($query2)) {
?>
<a href="<?php echo $array2['url']; ?>" class="<?php echo $i; ?>">
<?php echo $array2['text']; ?>
</a>
<?php
$i++;
if ($i == "c") {
$i = "a";
}
}
?>
</div>
</div>
<?php
}
}
?>
</div>
So any ideas on why my code is not doing it?

Categories