以复选框的形式从Mysql表的一列检索数据,并将所选内容发送到同一数据库的另一个表的另一列

以复选框的形式从Mysql表的一列检索数据,并将所选内容发送到同一数据库的另一个表的另一列,mysql,insert,checkbox,Mysql,Insert,Checkbox,我为我的无知道歉。我发誓我已经在谷歌上搜索了足够多关于这一点的信息,但没有找到任何具体的信息。我把代码看作一个形状,我的问题表明我是多么无知 关于复选框的问题都是关于复选框输入中直接命名的复选框:复选框值=红色、蓝色、粉色;或者大号、中号、x大号……等等。但是我没有发现任何关于从mysql表的列名称中检索到的复选框名称的信息,在这之后,返回并将其作为分隔值发送到BD的另一个列表 由于我不想让你读太多,我在这里放了一个屏幕截图: 如果需要,可以将表单作为演示查看 fore

我为我的无知道歉。我发誓我已经在谷歌上搜索了足够多关于这一点的信息,但没有找到任何具体的信息。我把代码看作一个形状,我的问题表明我是多么无知

关于复选框的问题都是关于复选框输入中直接命名的复选框:复选框值=红色、蓝色、粉色;或者大号、中号、x大号……等等。但是我没有发现任何关于从mysql表的列名称中检索到的复选框名称的信息,在这之后,返回并将其作为分隔值发送到BD的另一个列表

由于我不想让你读太多,我在这里放了一个屏幕截图:

如果需要,可以将表单作为演示查看
            foreach ( $_POST['AreaAuditada'] as $area )
            {
                $AreaAuditada_Post .= '[' . $area . ']';
            }
    <html>
    <head>
    </head>
    <body>
    <table class="print" style="width:80%" summary="Modificar auditorías">
    <caption><?php echo AINFORMES_ADMINISTRAR;
    include('acciones/acciones_ainformes.php'); ?></caption>  
    <tbody>
    <tr>
    <td><a href="?seccion=auditorias_admin&aktion=add"><?php echo AINFORMES_ANADIR; ?>  </a>::
    <a href="?seccion=auditorias_admin&aktion=change"><?php echo AINFORMES_CAMBIAR; ?> </a>
    </td>
    </tr>
    </tbody>
    </table>
    <br>


   <?php
        // requires the class
        require "class.datepicker.php";

        // instantiate the object
        $db=new datepicker();

        // uncomment the next line to have the calendar show up in german
        //$db->language = "dutch";

        $db->firstDayOfWeek = 1;

        // set the format in which the date to be returned
        $db->dateFormat = "Y-m-d";

// Aktionen
$aktion = '';
if(isset($_GET['aktion'])) $aktion = $_GET['aktion'];

if($aktion == ""){
 echo 'Admin Area';
 }

if($aktion == "add"){
if((empty($_POST['ai'])) AND (empty($_POST['Fecha'])) AND (empty($_POST['AreaAuditada'])) AND (empty($_POST['Documentacion'])) AND (empty($_POST['Auditor'])) AND (empty($_POST['ObjetoAuditoria']))  AND (empty($_POST['Resultado']))){
echo '<form action="" method="POST">';
   echo '<table class="print" style="width:80%" summary="Modificar auditorías">';
   echo '<caption>';
      echo AINFORMES_ANADIR;
  echo '</caption>';
   echo '<tbody>';
    echo '<tr>';
      echo '<th>';
      echo AINFORMES_NUMERO;
      echo '</th>';
       echo '<td>';
       echo ' <select name="ai" value="">';
             echo '<option>...</option>';

             $sql = "SELECT * FROM aisgc ORDER BY fecha DESC";
             $sql = mysql_query($sql);
             while($row = mysql_fetch_assoc($sql)) {
             //$row['ai'] = htmlentities($row['ai']);
             echo '<option value="'.$row[ai].'">'.$row[ai].' de fecha: '.$row[fecha].'</option>';
             }

       echo '</select>';
      echo '</td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo GENERAL_FECHA;
      echo '</th>';                     

      echo '<td><input type="text" id="date" class="inputfecha" name="Fecha" value="">';
      ?>

      <input type="button" value="::" onclick="<?=$db->show('date')?>">

      <?php
      echo '</td>';       

    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AINFORMES_AREA_AUDITADA;
      echo '</th>';



     // echo '<td><input class="inputlargo" name="AreaAuditada" value=""></td>';


     // SOME TESTS
       /*echo '<td>';
       echo ' <select name="AreaAuditada" value="">';
             echo '<option>...</option>';

             $sql = "SELECT * FROM areassensibles ORDER BY nombrearea";
             $sql = mysql_query($sql);
             while($row = mysql_fetch_assoc($sql)) {
             //$row['nombrearea'] = htmlentities($row['nombrearea']);
             echo '<option value="'.$row[nombrearea].'">'.$row[nombrearea].'</option>';
             }

       echo '</select>';
       echo '</td>';


       echo '<td>';
             $sql2 = "SELECT nombrearea FROM areassensibles ORDER BY nombrearea";
             $sql2 = mysql_query($sql2);
             define("nombrearea", "nombrearea");
             while($row = mysql_fetch_assoc($sql2)) {
             echo $row['nombrearea'];
             echo '<input type=checkbox name="AreaAuditada" value="'.$row[nombrearea].'">';
             }
        echo '<td>';*/


       echo '<td>';         
            $sql2="SELECT * FROM areassensibles";
            define("nombrearea", "nombrearea");
            $resultado=mysql_query($sql2); 
            while($nombrearea=mysql_fetch_array($resultado)){               
            echo '<input id="IDnombrearea[]" name="AreaAuditada[]" type="checkbox" value="'.$nombrearea[nombrearea].'">'.$nombrearea[nombrearea].'';                
            }               

        echo '<td>';            



    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo GENERAL_DOCUMENTACION;
      echo '</th>';
      echo '<td><input class="inputlargo" name="Documentacion" value=""></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AUDITORIAS_AUDITOR;
      echo '</th>';
      echo '<td>';
       echo ' <select name="Auditor" value="">';
             echo '<option>...</option>';

             $sql = "SELECT * FROM auditores WHERE activo=1";
             $sql = mysql_query($sql);
             while($row = mysql_fetch_assoc($sql)) {
             //$row['auditor'] = htmlentities($row['auditor']);
             echo '<option value="'.$row[auditor].'">'.$row[auditor].'</option>';
             }

       echo '</select>';
      echo '</td>';
      //echo '<td><input class="width:90%" name="Auditor" value=""></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AINFORMES_OBJETO;
      echo '</th>';
      echo '<td><textarea class="textareasmall" name="ObjetoAuditoria" value=""></textarea></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo GENERAL_RESULTADO;
      echo '</th>';
      echo '<td><textarea class="textareanormal" name="Resultado" value=""></textarea></td>';
      echo '</tr>';
      echo '<td colspan="2"><input type="submit" value="'.GENERAL_ANADIR.'"></td>';
    echo '</tr>';
   echo '</tbody>';     
  echo '</table>';
echo '</form>';
 }else{
$ai_Post = $_POST['ai'];
$Fecha_Post = $_POST['Fecha'];
$AreaAuditada_Post = $_POST['AreaAuditada'];



            foreach ( $_POST['AreaAuditada'] as $area )
            {
                $AreaAuditada_Post .= '[' . $area . ']';
            }



$Documentacion_Post = mysql_real_escape_string($_POST['Documentacion']);
$Auditor_Post = mysql_real_escape_string($_POST['Auditor']);
$ObjetoAuditoria_Post = mysql_real_escape_string($_POST['ObjetoAuditoria']);
$Resultado_Post = mysql_real_escape_string($_POST['Resultado']);
$sql =    mysql_query("INSERT INTO informeauditoria (ai, Fecha, AreaAuditada, Documentacion, Auditor, ObjetoAuditoria, Resultado) VALUES ('".$ai_Post."', '".$Fecha_Post."', '".$AreaAuditada_Post."', '".$Documentacion_Post."', '".$Auditor_Post."', '".$ObjetoAuditoria_Post."', '".$Resultado_Post."')");
if($sql) echo "Auditoría añadida";
else echo "Error al añadir el registro!";
}
}

if($aktion == "change"){
$sql = mysql_query("SELECT * FROM informeauditoria ORDER BY id DESC");

echo '<table class="print" summary="Modificar auditorías">';
echo '<caption>';
      echo AINFORMES_CAMBIAR;
  echo '</caption>';
echo '<thead>';
echo AINFORMES_ADVERTICE; 
echo '</thead>';
echo '<tbody>';
echo '<tr>';
//<!--<th>Id</th>-->';
 echo '<th>';
     echo AINFORMES_INFORME;
echo '</th>';
 echo '<th>';
     echo GENERAL_FECHA;
 echo '</th>';
echo '<th>';
     echo AINFORMES_AREA_AUDITADA;
echo '</th>';
 //<!--<th>Documentaci&oacute;n</th>-->
 echo '<th>';
     echo AUDITORIAS_AUDITOR;
 echo '</th>';
 //<!--<th>Objeto</th><th>Resultado</th>-->
echo '</tr>';
while($row = mysql_fetch_row($sql)) {
    echo "<tr>";  
    //echo "<td>".$row['0']."</td>";
    echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['1']."</a></td>";
    echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['2']."</a></td>";
    echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['3']."</a></td>";
    //echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['4']."</a></td>";
    echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['5']."</a></td>";
    /*echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['6']."</a></td>";
    echo "<td><a href='?seccion=auditorias_admin&aktion=change_id&id=".$row['0']."'>".$row['7']."</a></td>";*/
    echo "</tr>";
}
  echo '</tbody>';
 echo "</table>";
 }


 if($aktion == "change_id"){
 if((empty($_POST['ai_change'])) AND (empty($_POST['Fecha_change'])) AND (empty($_POST['AreaAuditada_change'])) AND (empty($_POST['Documentacion_change'])) AND (empty($_POST['Auditor_change'])) AND (empty($_POST['ObjetoAuditoria_change'])) AND (empty($_POST['Resultado_change']))){
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM informeauditoria WHERE id = $_GET[id] ");
$data = mysql_fetch_row($sql);

echo '<form action="" method="POST">';
  echo '<table class="print" summary="Modificar auditorías">';
  echo '<caption>';
      echo AINFORMES_PRINT_DETAILS;
  echo '</caption>';
   echo '<tbody>';
    echo '<tr>';
      echo '<th>';
     echo AINFORMES_INFORME;
     echo '</th>';
      echo '<td><input class="inputlargo" name="ai_change" value="'.$data[1].'"></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo GENERAL_FECHA;
      echo '</th>';
      echo '<td><input class="inputlargo" name="Fecha_change" value="'.$data[2].'"></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AINFORMES_AREA_AUDITADA;
      echo '</th>';
      echo '<td><input class="inputlargo" name="AreaAuditada_change" value="'.$data[3].'"></td>';
    echo '</tr>';
    echo '<tr>';
       echo '<th>';
     echo GENERAL_DOCUMENTACION;
      echo '</th>';
      echo '<td><input class="inputlargo" name="Documentacion_change" value="'.$data[4].'"></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AUDITORIAS_AUDITOR;
      echo '</th>';
      echo '<td><input class="inputlargo" name="Auditor_change" value="'.$data[5].'"></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo AINFORMES_OBJETO;
      echo '</th>';
      echo '<td><textarea class="inputlargo" rows="5" name="ObjetoAuditoria_change">'.$data[6].'</textarea></td>';
    echo '</tr>';
    echo '<tr>';
      echo '<th>';
     echo GENERAL_RESULTADO;
      echo '</th>';
      echo '<td><textarea class="textareanormal" rows="15" name="Resultado_change">'.$data[7].'</textarea></td>';
    echo '</tr>';
      echo '<td colspan="2"><input type="submit" value="'.GENERAL_MODIFICAR.'"></td>';
    echo '</tr>';
  echo '</tbody>';    
  echo '</table>';
echo '</form>'; 
}else{
$sql = mysql_query("UPDATE informeauditoria SET ai='$_POST[ai_change]',Fecha='$_POST[Fecha_change]',AreaAuditada='$_POST[AreaAuditada_change]',Documentacion='$_POST[Documentacion_change]',Auditor='$_POST[Auditor_change]',ObjetoAuditoria='$_POST[ObjetoAuditoria_change]',Resultado='$_POST[Resultado_change]' WHERE id=$_GET[id]");
if($sql) echo 'Auditor&iacute;a actualizada!';
}
}
?>
</body>
</html>