SELECT query using FIND_IN_SET() to match values in the separated commas

60 views Asked by At

I am trying to do dynamic nav menus for the pages, when admin creates a page, he selects multiple selection for the menus that this page should appears for, I am achieving this through two steps, 1st step adding the selected menus in the database separated by commas using implode(",", $assignNav) "1st step works successfully", 2nd step SELECT query using FIND_IN_SET() to match values in the separated commas.
Result in 2nd step: Just menus without commas "Assigned 1 value" is selected normally, but any pages with commas "assigned multiple values" did not return any output.

2nd Step Query:

                        <?php
                          $query = mysqli_query($dbConnection,"SELECT menu_name FROM navigation_menus WHERE FIND_IN_SET('3',menu_link_id) ");
                          queryConfirm($query);
                          while($row = mysqli_fetch_assoc($query)){
                            $menu_name = escape($row['menu_name']);
                        ?>
                        <h6 class="mb-0 text-sm"><?php echo htmlspecialchars($menu_name); ?></h6>
                        <?php
                          }
                        ?>
0

There are 0 answers