1

我为用户创建表单通过复选框选择所需的数据我有来自 sql 的数据表

<script>
$('input[type=checkbox]').live("change",function(){
    var target = $(this).parent().find('input[type=hidden]').val();
    if(target == 0)
    {
        target = 1;
    }
    else
    {
        target = 0;
    }
    $(this).parent().find('input[type=hidden]').val(target);
});
</script>
</head>

<body>
<div align="center">
<form id= "MyForm" method= "POST" action= "test_save.php">
<table width="70%" border="1" id="myTable">
<thead>
  <tr>
    <th width="5%"><div align="center">NO.</div></th>
    <th width="10%"><div align="center">ACCOUNT CODE</div></th>
    <th width="25%"><div align="center">ITEM NAME</div></th>
    <th width="5%"><div align="center"></div></th>
  </tr>
  </thead>
  <tbody>

<?php

$i=0;

while($i<$numr && $ven2 = $ven->fetch_assoc())
{$i++;

?>
<tr> 
<td><center><?php echo $ven2["id"]; ?></center></td>
<td><center><?php echo $ven2["acc_name"]; ?></center></td>
<td><?php echo $ven2["item_name"]; ?></td>
<td><center><input type="checkbox" ><input type="hidden" name="dataset[]" value="0" ></center></td>
</tr>
<?php
}
?>
</tbody> 
</table>

如果复选框 == 0 我想保留选择数据并上传到另一个数据库中的选择数据量将取决于用户没有固定我应该做什么这是 sql 我不知道如何使用哪个变量来支持帐户代码和项目名称

<?php
    ini_set('display_errors', 1);
    error_reporting(~0);

    $serverName = "localhost";
    $userName = "root";
    $userPassword = "1234";
    $dbName = "purchasenewtest";

    $conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
    mysqli_set_charset($conn, 'utf8');

    $data = $dataset[];

    if($data==0) {
    $sql = "INSERT INTO r(accountcode,orders) 
        VALUES ('".$_POST["x"]."','".$_POST["y"]."')";
    $query = mysqli_query($conn,$sql);
    }

    mysqli_close($conn);
?>
4

0 回答 0