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 6373517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:22:26+00:00 2026-05-25T01:22:26+00:00

i am sorry for the dummy question. Here is my simple PHP form with

  • 0

i am sorry for the dummy question. Here is my simple PHP form with two SQL tables and with the ADD submit button I would like to move people from Test1 to Test2. Many thing are fine:( only the submit button does’t work therefore no feedback from Test2 table.

Revised: Submit now works great

Q2 – still don’t get the checkboxs to work:( – please

Could somebody show me how to track back such an error like this please?

<?php include("db_connect.php");?>
<html>
  <head></head>
  <body>
    <form method="post" action="moving.php">
      <table border="1">
        <tr>
          <td>
            <?php
              $left='SELECT * FROM test1 ORDER BY name ASC';
              $result1=mysql_query($left);
              $count=mysql_num_rows($result1);
              while($resulta = mysql_fetch_array($result1)) {
                  ?>
                  <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $resulta['id']; ?>"/> <? echo $resulta['name']; ?>
                  <br />
            <?php } ?>
          </td>
          <td><input type="submit" id="add" name="add" value="Add" /></td>
          <td>
            <?php
              $rigth='SELECT * FROM test2,test1 WHERE test2.collect=test1.id ORDER BY test1.name ASC';
              $result2=mysql_query($right);
              while($resultb = mysql_fetch_array($result2)) {
                  echo $resultb['id'] ;
                  echo "<br />";
              }
            ?>
          </td>
        </tr>
      </table>
      <?php
        // Check if add button active, start this
        if (isset($_POST['add'])) {
            for ($i=0;$i<$count;$i++) {
                $add_id = $checkbox[$i];
                if ($add_id=='1') {
                  $sql = "INSERT INTO test2 (status, collect) VALUES(1, 1)";
                  $result = mysql_query($sql);
                }
            }

            // if successful redirect to delete_multiple.php
            if ($result){
                echo "<meta http-equiv=\"refresh\" content=\"0;URL=moving.php\">";
            }
        }
        mysql_close();
      ?>
    </form>
  </body>
</html>

thanks:) from a beginner

  • 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-05-25T01:22:27+00:00Added an answer on May 25, 2026 at 1:22 am

    the solution – not nice but it works – thanks for all the comments and help!!!

    <?php include("db_connect.php");?>
    
    <html>
    <head>
    </head>
    <body>
    <form method="post" action="test.php">
    

    New:

    <?php
    $left='SELECT * FROM test1 ORDER BY name ASC';
    $result1=mysql_query($left);
    $count=mysql_num_rows($result1);
    while($resulta = mysql_fetch_array($result1))
      {
    ?>
    
    <input name="checkbox_add[]" type="checkbox" id="checkbox_add[]" value="<? echo $resulta['id']; ?>"/> <? echo $resulta['name']; ?>
    <br />
    <?php
       }
    ?>
    
    </td> <td><input type="submit" id="add" name="add" value="Add" /><br /><input type="submit" id="delete" name="delete" value="Del" /></td><td>
    <?php
    $right='SELECT test2.id, test1.name FROM test2, test1 WHERE test1.id=test2.collect AND test2.status=1';
    $result2=mysql_query($right);
    while($resultb = mysql_fetch_array($result2))
      {
    ?>
       <input name="checkbox_del[]" type="checkbox" id="checkbox_del[]" value="<?php echo $resultb['id']; ?>"/>, <?php echo $resultb['id']; ?>, <? echo $resultb['name']; ?>
    <br />
    <?php
      }
    ?>
    </td></tr></table>
    
    
    <?php
    // Check if add button active, start this
    if (isset($_POST['add'])) {
      for ($c = 0; $c < count($_POST['checkbox_add']); $c++){
        $checkbox_add = $_POST['checkbox_add'][$c];
        $sql = "INSERT INTO test2 (status, collect) VALUES(1, ".$checkbox_add.")";
        echo $sql;
        $result = mysql_query($sql);
        if($result){
          echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">";
          }
        }
      }
    elseif (isset($_POST['delete'])) {
      for ($c = 0; $c < count($_POST['checkbox_del']); $c++){
        $checkbox_del = $_POST['checkbox_del'][$c];
        echo date("Y-m-d");
        $sql = "UPDATE  test2 SET status='2', log='".date('Y-m-d')."' Where id=".$checkbox_del;
        echo $sql;
        $result = mysql_query($sql);
        if($result){
          echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">";
         }
        }
      }
    elseif (isset($_POST['new'])) {
        $sql = "INSERT INTO test1 (status, name) VALUES(1, '".$_POST['newitem']."')";
        echo $sql;
        $result = mysql_query($sql);
        if($result){
          echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">";
        }
      }
    mysql_close();
    ?>
    
    </form>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the dummy question here. Under Windows I would like to be able
Sorry if this sounds like a really stupid question, but I need to make
Sorry for the Dummy Question , i know :( ,, but it's only the
Sorry for the probably dummy question but I'm lost. can Wi-fi network strength (dBm)
Sorry for the simple question, but I'm trying to find an elegant way to
Sorry for the dummy question but I'm a regular expressions newbie. I want these
Sorry for the basic question - I'm a .NET developer and don't have much
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Sorry for my ignorance here, but when I hear the word webserver, I immediately

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.