Jump to content

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?

you could name your radios as "action[$sqlresult->id]" with values of "delete" and "approve" then just do.

 

$actions = $_POST['action'];
foreach($actions as $id => $action){
if($action == 'delete') //etc ...
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.