Jump to content

Deleting multiple records from a checkbox


Arkane

Recommended Posts

Hey guys,

 

I've been asked to make a sort of admin system for a mysql database.  Theres very little to it, but for some reason it is demanded of me.

 

What I have just now is 2 checkboxs, and the record name displaying.  The checkboxes are written from the php, and have values of "approve" and "delete", while the names of both are $sqlresult->id

 

What I need is for them to process at the other end, so that every id with a value of "approve" will be updated, and "delete" will be deleted from the records, but I don't really have a clue how to do it.  Can anyone give any pointers?

 

Cheers

Give the checkboxes names of approve[] and delete[] then set their values equal to the id.

 

Like:

<input type="checkbox" name="approve[]" value="1" />

 

Then if its checked  you will have an approve array.

 

$approved = $_POST['approve'];
foreach($approved as $id){
//do whatever
}

Hey, thanks for the reply.

 

Unfortunately, I made a major mistake in my description.  what I actually want is the ability to do this from a radio box, not a checkbox.  I tried adapting the method given, but obviously it wouldn't work properly as the radios all have the same name.  Is there any way to change this to work with radios?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.