Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:26:19+00:00 2026-06-09T20:26:19+00:00

i have this problem this is the display from my view.php id menu +1

  • 0

i have this problem

this is the display from my view.php

id menu  +1 +2 +3

 1   bla_1 [] [] []
 2   bla_2 [] [] []
 3   bla_3 [] [] []

and this is my view code

<?php $i=1; foreach ($test as $row) : ?>
<tr>
<td><input type='hidden' name='id[]' value="<?php echo $row->menu_id ?>" /></td>
<td><input type="text" name="Menu" value="<?php echo $row->menu_nama ?>" disabled <td>
<td><input type="checkbox" name="<?php echo 'menu_id[]'; ?>" value="+1"  /></td>
<td><input type="checkbox" name="<?php echo 'menu_id[]'; ?>" value="+2"  /></td>
<td><input type="checkbox" name="<?php echo 'menu_id[]'; ?>" value="+3"  /></td>
</tr>
<?php $i++; endforeach ; ?>

if i check the first checkbox i will get +1, the second checkbox i will get +2

my goal is to join the input from every checked checkbox and save to database based on id

and this is my code on model to join the value of checkbox

$menu_id= $this->input->post('menu_id');        
        $menu_idc = '';

        $count = count($menu_id);
        $i=0;
        foreach($menu_id as $e){ 
            if($i < $count -1)
            {
                $menu_idc .= $e.'';
                echo $i ;
            }
            else{
                $menu_idc .= $e.'+';
                }
                $i++;
            }
            var_dump($menu_idc);
            die;

from example if i check this checkbox

         id menu   +1   +2  +3

         1   bla_1 [v] [v] [v]
         2   bla_2 []  [v] []
         3   bla_3 []  []  [v]

with code i write i will get +1+2+3+2+3+ (+1+2+3 from row 1, +2 from row 2, +3 from row 3)

what i want is to get is value from every row and save to table on database

+1+2+3+ save into database

+2+ save into database

+3+ save into database

    Database
id   | isi     |
1    | +1+2+3+ |
2    | +2+     |
3    | +3+     |

i think i must loop the code on my model but i dont know what code i have to write

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:26:21+00:00Added an answer on June 9, 2026 at 8:26 pm

    What you need is a 2-dimensional array. The first dimension is for the row and the second one is for the columns.

    First change your markup a bit to make the submitted values 2-dimensional:

    <?php $i=1; foreach ($test as $row) : ?>
      <tr>
        <td><input type='hidden' name="menu[<?php echo $i ?>][id]" value="<?php echo $row->menu_id ?>" /></td>
        <td><input type="text" name="menu[<?php echo $i ?>][menu]" value="<?php echo $row->menu_nama ?>" disabled <td>
        <td><input type="checkbox" name="menu[<?php echo $i ?>][plus][]" value="+1"  /></td>
        <td><input type="checkbox" name="menu[<?php echo $i ?>][plus][]" value="+2"  /></td>
        <td><input type="checkbox" name="menu[<?php echo $i ?>][plus][]" value="+3"  /></td>
      </tr>
    <?php $i++; endforeach ; ?>
    

    This code should work fine:

    $menus = $this->input->post('menu');        
    
    foreach ($menus as $menu)
    {
      $id = $menu['id'];
      $name = $menu['name'];
      $menu_ids = "";
    
      if (is_array($menu['plus']))
      {
        $menu_ids = join('', $menu['plus'])).'+';
      }
    
      // here you can save it now by executing a sql update or whatever
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem: I want to generate a new source code file from
I have this problem having to display my jasper report on my grails application.
I have this mysql tables I want to display with jqgrid. The problem appears
I have this problem in my SlashDot Menu. I want to change the picture
i have problem to pass data from view to controller , i have view
i have this problem that i can't solve for days now...here is my code.
I got a problem, I have this code: $(document).ready(function(){ /* The following code is
I have this problem regarding my Jasper Report on Grails wherein I should display
I have this problem: $id is id for each user $img = 'http://www.somesite.com/pictures/'; $no_img
I have this problem since I'm beginning in OOP programming I want to close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.