将HTML表中的多行插入数据库

时间:2018-05-11 16:54:26

标签: php mysql

我认为我的问题是在隐藏字段中检索id

while( $row = mysqli_fetch_assoc($result)){

    echo "<tr><td><form action='workshopreq.php' method='POST'> <td=width='5%'><input type='checkbox' name='foo' value='bar1'/>  </td>"."<td>". $row["wID"]. "</td><td>" . $row["wName"]. "</td><td width='10%'>" . $row["services" ]. "</td><td>" . $row["other"]. "</td><td width='5%'>" . $row["area"]."</td>";

    echo "<td><input type='hidden' name='status' value='".$row["wID"]."'><input type='submit' name='conf' value='confirm'></td><td><input type='submit' name='decline' value='decline'></td></form></tr>";


}  


if(isset($_POST['conf'])){

        $sql1= "INSERT INTO acceptedWS(wName, wEmail, wPass, services, other, Workshop, area, starthr, endhr,clock1,clock2)
       SELECT  wName, wEmail, wPass, services, other, Workshop, area, starthr, endhr,clock1,clock2 FROM Workshop where Workshop.wID='".$row["wID"]."'";
        $res= mysqli_query($conn,$sql1);

       }

if(isset($_POST['decline'])){

//delete from database

}


 echo "</table>"; }

提前致谢!

0 个答案:

没有答案