Jump to content

Approving multiple pictures


Icedz

Recommended Posts

I'm putting together a site where users can upload pictures.  Each picture that gets uploaded is going to be verified by an admin.  The pictures will be uploaded, but will have a flag of "not_activated" in a database.  Let's say one day I get 100 pictures uploaded.  How can I approve multiple at one time?  For example, have a page come up with x at a time (I can do that), with either a check box or radio buttons approving or not approving the pics. 

Thanks!

Link to comment
Share on other sites

Name each checkbox something like "approve[]" and make the value the Images ID from the DB.

 

EX.

<input type="checkbox" name="approve[]" value="{$row['images_ID']}">

 

Then at the top of the script put this code:

 

<?php

if (isset($_POST['your_submit_button'])){

   if (!empty($_POST['approve'])){

      foreach ($_POST['approve'] as $imageID){
         $imageID = (int)$imageID;
         $query = mysql_query("UPDATE image_table SET approved='yes' WHERE imageID=$imageID")or die(mysql_error());
      }
   }
   
   echo "Images Approved";
}

?>

 

Obviously change the queries to match your database.

Link to comment
Share on other sites

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.