我无法理解为什么这不会被执行到mySQL数据库中? 一切都已设定,它所做的只是更新一些值。
<?php
$con=mysqli_connect(This is filled.);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE `members` SET `rank`='$_POST[rank]' WHERE `id`='$_POST[id]'");
mysqli_close($con);
header("Location: index.php");
?>
继承人应该填充$ _POSTs
<form action="setrank.php" method="post">
User:
<select>
<?php
$result = mysqli_query($con,"SELECT * FROM members ORDER BY id");
while($row = mysqli_fetch_array($result))
{
echo "<option name='id' id='id' value='" . $row['id'] . "'>" . $row['username'] . " (" . $row['id'] . ")</option>";
}
?>
</select><br />
Set rank to:
<select><option name="rank" id="rank" value="0" >Guest.</option><option name="rank" id="rank" value="1" >Moderator.</option><option value="2" name="rank" id="rank">Administrator.</option><option value="3" name="rank" id="rank">Owner.</option></select>
<br /><input type="submit">
</form>
非常感谢您的帮助,我一直在使用小时。 :/
答案 0 :(得分:1)
表单select
元素定义不正确,在name
中添加表单字段select box
而不是选项请尝试这种方式
<select name="id">
<option value="xyz">Name</option>
</select>