These are chat archives for codeigniter-id/codeigniter-id.github.io

20th
Nov 2017
Samuele
@eleumas
Nov 20 2017 11:26

Hi @aanlinuxer, thanks for your answer and for have help me.
So i have change my code but doesn't work:

<tbody>
            <?php
            $query = $this->db->query("SELECT * FROM menus");
            var_dump($query->result());
            foreach($query->result() as $row) : ?>
              <tr>
                <td><input class="uk-checkbox" type="checkbox" name="checkbox[]" value="<?php echo $row->id; ?>"></td>
                <td><span class="uk-label"><?php echo $row->id; ?></span></td>
                <td><span class="uk-label"><?php echo $row->parent; ?></span></td>
                <td><?php echo $row->name;?> <?= if ($row->parent == $row->id) { echo "sobcategory"; } ?></td>
              </tr>
            <?php endforeach; ?>
          </tbody>

This is my database:

database.png
Samuele
@eleumas
Nov 20 2017 11:31
with var_dump($query->result());
i have this error:
array(11) { [0]=> object(stdClass)#30 (6) { ["id"]=> string(1) "1" ["parent"]=> NULL ["name"]=> string(18) "Non Categorizzato " ["icon"]=> string(24) "glyphicon glyphicon-user" ["slug"]=> string(6) "Item-0" ["number"]=> string(1) "1" } [1]=> object(stdClass)#31 (6) { ["id"]=> string(1) "2" ["parent"]=> NULL ["name"]=> string(5) "Auto " ["icon"]=> string(26) "glyphicon glyphicon-remove" ["slug"]=> string(6) "Item-1" ["number"]=> string(1) "2" } [2]=> object(stdClass)#32 (6) { ["id"]=> string(1) "3" ["parent"]=> NULL ["name"]=> string(8) "Animali " ["icon"]=> string(0) "" ["slug"]=> string(6) "Item-2" ["number"]=> string(1) "3" } [3]=> object(stdClass)#33 (6) { ["id"]=> string(1) "4" ["parent"]=> NULL ["name"]=> string(7) "Piante " ["icon"]=> string(0) "" ["slug"]=> string(6) "Item-3" ["number"]=> string(1) "4" } [4]=> object(stdClass)#34 (6) { ["id"]=> string(1) "5" ["parent"]=> NULL ["name"]=> string(6) "Altro " ["icon"]=> string(0) "" ["slug"]=> string(6) "Item-4" ["number"]=> string(1) "5" } [5]=> object(stdClass)#35 (6) { ["id"]=> string(2) "10" ["parent"]=> string(1) "2" ["name"]=> string(4) "Fiat" ["icon"]=> string(0) "" ["slug"]=> string(10) "item-0-1-1" ["number"]=> string(1) "1" } [6]=> object(stdClass)#36 (6) { ["id"]=> string(2) "11" ["parent"]=> string(1) "2" ["name"]=> string(4) "Audi" ["icon"]=> string(0) "" ["slug"]=> string(10) "Item-0-1-2" ["number"]=> string(1) "2" } [7]=> object(stdClass)#37 (6) { ["id"]=> string(2) "12" ["parent"]=> string(1) "3" ["name"]=> string(5) "Terra" ["icon"]=> string(0) "" ["slug"]=> string(12) "Item-0-1-1-1" ["number"]=> string(1) "1" } [8]=> object(stdClass)#38 (6) { ["id"]=> string(2) "13" ["parent"]=> string(1) "3" ["name"]=> string(5) "Acqua" ["icon"]=> string(0) "" ["slug"]=> string(12) "Item-0-1-1-2" ["number"]=> string(1) "2" } [9]=> object(stdClass)#39 (6) { ["id"]=> string(2) "15" ["parent"]=> string(1) "4" ["name"]=> string(6) "Alberi" ["icon"]=> string(0) "" ["slug"]=> string(8) "item-1-2" ["number"]=> string(1) "2" } [10]=> object(stdClass)#40 (6) { ["id"]=> string(2) "16" ["parent"]=> string(1) "4" ["name"]=> string(5) "Fiori" ["icon"]=> string(0) "" ["slug"]=> string(8) "item-2-2" ["number"]=> string(1) "2" } }