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

  • SEARCH
  • Home
  • 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 523719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:29:29+00:00 2026-05-13T08:29:29+00:00

Ok, first off, I applogize if this question has been asked before, I’ve spent

  • 0

Ok, first off, I applogize if this question has been asked before, I’ve spent the last 12 hours sifting through hundreds of forum threads and haven’t found one that answers this question exactly yet so here goes.

I have a page that I built that has a userlist that is autopopulated as users log in, and each users has a checkbox that allows the host to select users and removed them if needed. I am using jQuery to send an array string to a php page where I am attempting to explode the string, walk through the userids and remove the passed ids from our database. It all works exceedingly well, unless I select more than one user. When I select more than one user and pass the array to the php handler, it explodes the array but only keeps the last value in the array, the rest of it is lost somewhere in the blackhole of scripting.

Here is my code from my javascript page:

function rem_user() {  
var ids = $('input:checkbox[id=del]:checked').map(function(){
    return this.value
}).get();
alert(ids);
jQuery("#rem_msg").load(controlpage, {AdmFnc: "rem_user", del_ids: ids}, getUsers);
}

this array is then passed to the php controlling page where it is handled by:

if (strcmp($AdmFnc, rem_user) == 0){
echo "";
$ids = trim($_POST['del_ids']);
$ids = explode(',',$ids);
if(is_array($ids)){
   foreach($ids as $userid){
      mysqli_query($dbc, "UPDATE webcastlogin SET logoutTime = '$current_time' WHERE userid = '$userid'") or die('Error setting logout time '.mysqli_error($dbc));
      mysqli_query($dbc, "DELETE FROM weekly_users WHERE userid = '$userid'") or die('Error removing users '.mysqli_error($dbc));
    }
    echo 'Selected IDs removed';
} else if (empty($ids)) {
    echo 'Code is wrong, no array sent';
} else {
    mysqli_query($dbc, "UPDATE webcastlogin SET logoutTime = '$current_time' WHERE userid = '$ids'");
    mysqli_query($dbc, "DELETE FROM weekly_users WHERE userid = '$ids'");
    echo 'Selected ID removed';
}
}

As you can see on my javascript, i have an alert set up so i can verify that the information being sent is correct, as far as i can tell from that alert, it’s a "," delimited array so that’s what i’m using on the php side to explode it.

I am at my wits end trying to figure out why when I run this thru the foreach loop i only get the value of the final item in the array.

Any help would be greatly appreciated and may save my hair for some future coding challanges.

Thanks

  • 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-05-13T08:29:30+00:00Added an answer on May 13, 2026 at 8:29 am

    Just change your key name for del_ids in the jQuery load call to include an empty set of brackets:

    jQuery("#rem_msg").load(controlpage, {AdmFnc: "rem_user", "del_ids[ ]": ids}, getUsers);
    

    Now, in the PHP, instead of using trim and explode, the values will already be in an array, so you can access them directly:

    $ids = $_POST['del_ids'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.