Jump to content

Recommended Posts

I have a question about deleting database results.  In the past, I just use a button that takes a user to a "are you sure" page and it just deletes that result.  I now need a more efficient way of deleting database results since I will have alot more results showing.  I need to be able to delete more than one database result at one time.  I have seen scripts that delete results according to certain checkboxes that are checked.  I was wondering how I would do this if this was my current code:

 

 $query = mysql_query("SELECT sid,filename,is_private FROM recent_files WHERE userID = '$uid' ORDER BY sid DESC LIMIT 20") or die("Error: ".mysql_error());

echo "<table align='center' cellspacing='1' cellpadding='1' border='0' width='65%' style='background-color: #000000;'>
               <tr><form>
                    <td width='50%' style='background-color: #e4e4e4;'>Image</td><td width='50%' style='background-color: #e4e4e4;'>Delete?</td>
               </tr><tr>";

              while($fetch=mysql_fetch_array($query)){

              $sid=$fetch["sid"];
              $filename=$fetch["filename"];
              $is_private["is_private"];

              echo "<td width='50%' style='background-color: #e4e4e4;'>$filename<br><br><a href='image.php?img=$filename'><img src='uploads/$filename' alt='$filename' width='50' height='50' border='0'></a></td><td width='50%' style='background-color: #e4e4e4;'><input type='checkbox' name='delete$sid'></td>
               </tr>";

              }

echo "<td align='center' colspan='2'><input type='submit' value='Delete' name='submit'></form></table>";

 

Thanks in advance for any help that is provided.

Link to comment
https://forums.phpfreaks.com/topic/55194-question/
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.