The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert multiple from input checkbox
#19
I'm not 100{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} following, but I think I'm getting the gist of what is going on.

You can put something inside the [] on your form input if you need to.

So in other words, if you have
Code:
<input type='checkbox' name='utilizator[]' autocomplete='off' value=''>

You can either put an $id or you can take that thing from my pastebin where I did the insert and then put
Code:
$db->insert('task_list_sub',$fields);
Code:
$newTaskId = $db->lastId();

You can take that newTaskId and put it in your name field
Code:
name='utilizator[<?=$newTaskId]'

Then, when you are in your form processing

Code:
if(!empty($_POST)){
Code:
foreach($_POST['utilizator'] as $key => $value) {
//You'll see that you can
Code:
dump($key);
//and
Code:
dump($value);
//and you have that information separately.
Code:
}

So, here is an example of where I use this in an online ordering system.
http://pastebin.com/sUqszW8h
On line 6 I want to make sure that the quantity is not 0 or less (if it is, I ignore it)
Then I take each row and turn it into a key->value pair
Then I go row by row and multiply my price x quantity to get the total cost
Then I check to see if that order number was already in the system
If it was, I update the order
If it was not, I insert a new one.
  Reply


Messages In This Thread
Insert multiple from input checkbox - by picassoo - 12-20-2016, 07:57 PM
Insert multiple from input checkbox - by picassoo - 12-20-2016, 08:15 PM
Insert multiple from input checkbox - by mudmin - 12-21-2016, 03:00 PM
Insert multiple from input checkbox - by picassoo - 12-21-2016, 06:06 PM
Insert multiple from input checkbox - by picassoo - 12-21-2016, 06:16 PM
Insert multiple from input checkbox - by picassoo - 12-21-2016, 06:44 PM
Insert multiple from input checkbox - by mudmin - 12-21-2016, 08:26 PM
Insert multiple from input checkbox - by picassoo - 12-21-2016, 10:09 PM
Insert multiple from input checkbox - by mudmin - 12-22-2016, 02:03 PM
Insert multiple from input checkbox - by picassoo - 12-22-2016, 08:49 PM
Insert multiple from input checkbox - by mudmin - 12-22-2016, 10:20 PM
Insert multiple from input checkbox - by picassoo - 12-23-2016, 09:47 AM
Insert multiple from input checkbox - by mudmin - 12-23-2016, 01:47 PM
Insert multiple from input checkbox - by picassoo - 12-23-2016, 10:52 PM
Insert multiple from input checkbox - by mudmin - 12-23-2016, 11:10 PM
Insert multiple from input checkbox - by mudmin - 12-23-2016, 11:12 PM
Insert multiple from input checkbox - by picassoo - 12-24-2016, 11:46 AM
Insert multiple from input checkbox - by picassoo - 12-24-2016, 11:48 AM
Insert multiple from input checkbox - by mudmin - 12-24-2016, 04:05 PM
Insert multiple from input checkbox - by picassoo - 12-24-2016, 08:25 PM
Insert multiple from input checkbox - by picassoo - 12-24-2016, 09:16 PM
Insert multiple from input checkbox - by mudmin - 12-25-2016, 07:35 PM
Insert multiple from input checkbox - by mudmin - 12-25-2016, 08:35 PM
Insert multiple from input checkbox - by picassoo - 12-26-2016, 06:54 PM
Insert multiple from input checkbox - by dan - 12-26-2016, 07:16 PM
Insert multiple from input checkbox - by picassoo - 12-26-2016, 08:07 PM
Insert multiple from input checkbox - by dan - 12-26-2016, 09:55 PM
Insert multiple from input checkbox - by picassoo - 12-27-2016, 05:52 AM
Insert multiple from input checkbox - by dan - 12-27-2016, 06:07 AM
Insert multiple from input checkbox - by picassoo - 02-10-2017, 09:53 PM
Insert multiple from input checkbox - by mudmin - 02-11-2017, 02:47 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)