473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I have 3 selectbox ,if i select two checkbox that value only insert to database ?

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.                             <th>Read</th>
  3.                             <th>Write</th>
  4.                             <th>Delete</th>
  5.                             </tr>
  6.                             <tr>
  7.                             <td ><input type="checkbox" name="admin_access[]" id="admin_read"  /></td>
  8.                             <td><input type="checkbox" name="admin_access[]" id="admin_write" /></td>
  9.                             <td><input type="checkbox" name="admin_access[]" id="admin_delete"/></td>
  10.                             </tr>
----------------------
model

Expand|Select|Wrap|Line Numbers
  1. $admin_access=$_POST['admin_access'];  
  2.             $chk="";  
  3.             foreach($admin_access as $chk1)  
  4.             {  
  5.             $chk .= $chk1.",";  
  6.  
  7.             } 
  8.         try {
  9.             $collection = $this->mongoClient->{$this->collectionName};
  10.             // Check already we have data about this supplier
  11.             $recordsFiltered = $collection->count(['name' => $data['name'], 'password' => $data['password']]);
  12.             if ($recordsFiltered > 0) {
  13.                 throw new Exception('This user details already exist in our system');
  14.             }
  15.  
  16.             $insertOneResult = $collection->insertOne([
  17.                 'name' => trim($data['name']),
  18.                 'email' => trim($data['email']),
  19.                 'password' => trim($data['password']),
  20.                 'usertype' => trim($data['usertype']),
  21.                 'admin_access' => trim($chk),
  22.  
  23.             ]);
Attached Images
File Type: jpg 1.jpg (20.7 KB, 144 views)
File Type: jpg 2.jpg (11.6 KB, 95 views)
Feb 9 '17 #1
1 1022
Dormilich
8,658 Expert Mod 8TB
What is the problem you're having?
Feb 10 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
1
by: Art | last post by:
Hi, I have a problem with checkbox value on the page connected to MS Access. Ms Access field is: Independent - Data Type: Yes/No My code is: <form name="form" method="post"...
1
by: Jerim79 | last post by:
I have a simple 3 page registration form. One form, one "data validation" script and one "insert into database" script. The customer bounces back and forth from the form to the verification script...
11
by: manjunath1985 | last post by:
Hi, I am really having problem in checkbox.... i have a php page which displays the username retrieved from the database i want to create a checkbox for each username and pass the selected...
1
by: inamul | last post by:
I want to select CheckBox based on data retrieved from mysql database table. Could anyone show me the simple way of doing it. Data store in table under colum "sectionOfInterest" is shown below...
1
by: arial | last post by:
I am having problem inserting checkbox value into database table. My database field is of type char(1). and my code is like this: string cc= null; if (chkdiscipline.checked) { cc = "T";
6
selvasoft
by: selvasoft | last post by:
Hi Please help me i want to store all the details like orderno and shadeno and uploaded image file also. all are in one table. Find my attachment , when am select that check box that order...
1
by: JSharma | last post by:
Hii Everyone I am having a problem while inserting the checkbox values into database after posting. I am actually getting the Checkbox fields from Database .Now I want to insert the Checked field...
0
by: safuta | last post by:
i need help here. how do i display checkbox value from my database MS access in a visual basic 6 form? i hv 2 checkbox in my form, which are Available and Not Available. if the value is yes, i want...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.