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
https://forums.phpfreaks.com/topic/97731-approving-multiple-pictures/
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.

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.