Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8230563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:10:50+00:00 2026-06-07T17:10:50+00:00

I have created a form that update the data in a sql column, so

  • 0

I have created a form that update the data in a sql column, so far all good.
The problem I have is that I would like to choose what columns are going to be updated, with checkboxes.
So I want to categorize two files as movies, I just check the checkbox and write movies in the form.

But its not only that. Every column is already connected to a checkbox, but I use this checkbox with an delete query, so I can delete multiple rows.

So my question is more like, how can I combine this two function with “one” checkbox.

This is some of my code.

This is my table with the sql outputs, and with the delete button

<?php  
$files = mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` DESC LIMIT $start, $per_page")
    or die(mysql_error()); 
    ?>
<table id="table-3">
 <thead>
        <tr>
            <th scope="col">Upload User</th>
            <th scope="col">Filename</th>
            <th scope="col">Upload date</th>
             <th scope="col">IP adress</th>
             <th scope="col">Category</th>
            <th scope="col">Delete</th>
        </tr>
    </thead>
<?php
while (($row = mysql_fetch_assoc( $files )) !==false)
{ 
echo "<tr>"; 
echo "<td>".$row['user_name'] . "</td> ";
?>
<td class="download"> <a href="download.php?file_id=<?php echo $row ['file_id']; ?>"> <?php echo $row['file_name']; ?></a></td>
<?php echo "<td>".$row['file_time'] . "</td> "; ?>
<?php echo "<td>".$row['file_ip'] . "</td> "; ?>
<?php echo "<td>".$row['category'] . "</td> "; ?>
<td>

<form action="delete.php" method="post">
<input type="checkbox" name="done[]" id="<?php echo $row['file_id'] ?>" value="<?php echo $row['file_id'] ?>">

</td>

<?php 
}
    echo "</tr>";
    echo "</table>"; 
 ?>
<input type ="submit" value ="Delete">
</form> 

This form is the one with the update function

 <form action="function.php" method="post">
category: <input type="text" name="category" />
<input type="submit" />
</form>

and
function.php

include('core/inc/init.inc.php');

    if(isset($_POST['category'])){
    $category = $_POST['category'];
    mysql_query("UPDATE files SET category='$category'
    /*WHERE category='genom' */ ");

    header("Location: profile.php?uid=" . $_SESSION['uid']);
    }else{
    header("Location: profile.php?uid=" . $_SESSION['uid']);
    };

How can I combine these two functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:10:51+00:00Added an answer on June 7, 2026 at 5:10 pm

    You can have multiple submit buttons in the same form. So you can do something like this:

    <?php  
        $files = mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` DESC LIMIT $start, $per_page")
        or die(mysql_error()); 
    ?>
    <form action="updateordelete.php" method="post">
        <table id="table-3">
            <thead>
                <tr>
                    <th scope="col">Upload User</th>
                    <th scope="col">Filename</th>
                    <th scope="col">Upload date</th>
                    <th scope="col">IP adress</th>
                    <th scope="col">Category</th>
                    <th scope="col">Delete</th>
                </tr>
            </thead>
            <?php
            while (($row = mysql_fetch_assoc( $files )) !==false)
            {
            ?>
            <tr>
                <td> <?php echo $row['user_name']; ?></td>
                <td class="download"> <a href="download.php?file_id=<?php echo $row ['file_id']; ?>"> <?php echo $row['file_name']; ?></a></td>
                <td><input type="text" name="file_time[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['file_time']; ?>" /></td>
                <td><input type="text" name="file_ip[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['file_ip']; ?>" /></td>
                <td><input type="text" name="file_category[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['category']; ?>" /></td>
                <td><input type="checkbox" name="done[]" id="<?php echo $row['file_id'] ?>" value="<?php echo $row['file_id'] ?>"></td>
            </tr>
            <?php } ?>
        </table>
        <input type ="submit" name="submittype" value = "Update">
        <input type ="submit" name="submittype" value = "Delete">
    </form> 
    

    And then, in updateordelete.php:

    if($_POST['submittype']=="Delete"){
       (do delete code...)
    }elseif($_POST['submittype']=="Update"){
       (do update code...)
    }
    

    For each of the values, you can access them using $_POST[‘file_category’]. For example:

    $file_categories=$_POST['file_category'];
    foreach($_POST['done'] as $file_id){
        echo $file_categories[$file_id];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a form that needs to show data from 2 tables (parent
I have created a form that contains fields used to accept a floating value
I have created a form that is used for both adding and editing a
I have created a list form that gets attached to a main form in
I have created a form with knockout that will allow the ability to give
I have created a macro for excel which will pop up form that contains
if i have created a view model and have a partial form that is
I have created a non-form c# program that uses the NotifyIcon class. The text
I have a form that is dynamically created, on this form are several radio
I have a textbox in a form that I created. I want to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.