The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (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
Array Delete
#1
I have a table that contains, id and pcnumber.

I can add new entries to the DB fine however want to replicate the array delete similar to removing users / permission groups etc by selecting check boxes. I thought this would be as easy as copying what in the admin_users.php and amending the deleteUsers function however can't seem to make it work.

I can see there is a deletebyId class however I'm not sure how to make this work / if this would be a better approach.

In the source code when the page is loaded, the correct ID is shown in each checkbox field, corresponding to the correct it / pcnumber; however this breaks when I try to put the [count] part in although i wasn't sure if this was needed given the correct IDs are already being returned.

Kind of minimal information but but hopefully outlines what I'm trying to achieve.

Any help appreciated,

Thanks

  Reply
#2
The easiest thing is to do something like a foreach loop. So the checkboxes should represent the id of the row you're trying to delete.

Let's say they're all assigned to $deleteme

Code:
foreach ($deleteme as $d){
Code:
$db->query("DELETE FROM mytable WHERE id = ?",array($d));
Code:
}

That should do it.
  Reply
#3
Perfect, thanks, that did the trick.
  Reply
#4
With this patch you can do this:

Code:
$db->delete("mytable",["id","IN",$array])
  Reply
#5
I'm definitely going to look at rolling that out. I have 5 more weeks of camp coming up at my job and then it's back to coding.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)