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 =?即可。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号