gpt4 book ai didi

php:处理选择标签

转载 作者:行者123 更新时间:2023-11-29 23:41:54 24 4
gpt4 key购买 nike

此代码运行,但在测试时..数据不正确,我从数据库中选择数据,并将其放入数组中,并通过选择标签显示它的ID,但当选择任何ID并提交时..示例我选择5并单击提交记录将删除是2而不是5

<?php
require_once "config.php";
$qid="select id from info_user";
$arrayid=array();
$result=mysql_query($qid);
while($res=mysql_fetch_array($result)){
$arrayid[]=$res['id'];
}
var_dump($arrayid);
if(isset($_POST['sub'])){
$id=$_POST['id'];
$q="delete from info_user where id=$id ";
$qq=mysql_query($q);
if($qq){
echo "you delete record ";
}
else{
echo "error in deleting";
}}
?>
<html>
<head>
<title>delete</title>
</head>
<form action="delete.php" method="post">
<select name="id"><?php for($i=0;$i<count($arrayid);$i++){?>
<option value="<?php echo $i;?>"><?php echo $arrayid[$i];} ?></option></select> <br />
<input type="submit" name="sub" />
</form>
</html>

最佳答案

我认为这个问题在于选项的值(value)。

尝试将选项行更改为

<option value="<?php echo $arrayid[$i];?>"><?php echo $arrayid[$i];} ?></option></select> <br />

关于php:处理选择标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26120891/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com