Rumah >pembangunan bahagian belakang >tutorial php >PHP 在table中删除一条记录
PHP在table中删除一条记录
各位好,初次接触PHP弱弱的文革问题,<script language="javascript" > function Delete11(var id) { ................. }</script><form action="delete.php" method = "post"> <table border = "1" cellpadding = "3" align = "center"> <tr> <th>编号</th> <th>商品名称</th> <th>商品货号</th> <th>商品价格</th> <th>促销价</th> <th>操作</th> </tr> <?php include ('..\Conn\ConnectionDB.php'); $sql = "select *from products"; $result = mysql_query($sql); $row = mysql_fetch_row($result); while ($row){ ?> <tr> <td><?php echo $row[0]?></td> <td><?php echo $row[3]?></td> <td><?php echo $row[2]?></td> <td><?php echo $row[11]?></td> <td><?php echo $row[12]?></td> <td><button onclick = Delete11(<?php echo $row[0]?>)>删除</button></td> </tr> <?php $row = mysql_fetch_row($result);} ?> </table></form>
不用 js
不用 js
通过js传递主键id到服务端,服务端接收参数执行sql delete * from table where id =?即可。