Welcome Guest, Not a member yet? Register   Sign In
Duplicate foreach
#1

(This post was last modified: 03-30-2024, 05:11 PM by FlavioNeves. Edit Reason: code was wrong )

Hello everybody!
I've been having a problem for a few days, and I can't solve it.
Can anyone help me?

I have a filter, where I am doing a join, but I am getting duplicate results.

$modelApp = new \App\Models\App();
$menuPai = new \StdClass();
$request->menuPai = $modelApp->select('apps.*, appmenus.menuAdmin submenu')
->join('appmenus', 'appmenus.app_url_admin = apps.urlAdmin', 'left')
->findAll();
return $request;

The Email main menu should appear once, and below it show the Enviar and Criar submenus.

However, the Email main menu is repeating.


[Image: jpwQW3I.png]
Reply
#2

You need to show your code if you want help.

show the code for your foreach loops etc.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Are you certain you are not prefilling the menu or calling the append method twice somewhere in the code ?
Web developer creating tools for streamers
Countdown Tools: https://obscountdown.com
Reply
#4

(This post was last modified: 03-31-2024, 01:08 AM by FlavioNeves.)

the code is just what I put above, nothing more. It's a before filter.

in view it looks like this


<aside id="sidebar" class="sidebar">

    <ul class="sidebar-nav" id="sidebar-nav">

      <?php foreach ($menuPai as $menuPai) { ?>
       
        <?= esc($menuPai->menuAdmin); ?> <br>

        <?= esc($menuPai->submenu); ?> <br><br>

      <?php } ?>

    </ul>

  </aside>

[Image: iGMVhlS.png]
Reply
#5

Where's your html code for <li> and <dropdown> etc?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

I already managed to solve it, but I didn't relate the tables, it wouldn't work this way.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB