我的代码在下面
<form action="POST">
<td class="tg-yw4l" ><?PHP echo $_CONFIG['item_Id']?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['item_Name']?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['itemPicture']?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['market_Value']?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['bptf_Value']?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['opskins_Value']?></td>
<td class="tg-yw4l" ><input name="sell" placeholder="<?PHP echo "$".$Sell_Price?>" value="<?PHP echo $Sell_Price?>"></td>
<td class="tg-yw4l" ><input name="keys" placeholder="<?PHP echo $Keys_Price."K"?>" value="<?PHP echo $Keys_Price?>"></td>
<td class="tg-yw4l" ><input name="refs" placeholder="<?PHP echo $Refs_Price."R"?>" value="<?PHP echo $Refs_Price?>"></td>
</form>
它在表中,输入名称sell可以通过我的PHP后端代码保存到SQL,并且不确定为什么名称键和名称引用不起作用;我的意思是它确实有文本框,但没有将其保存到SQL。
这是它的后端PHP代码:
if (isset($_POST['submit'])) {
if($s_Bot_Id == $f_Bot_Id ){
if(isset($_POST['sell'])){
$content = $_POST['sell'];
$sql_table = "bot_items_db";
$sql = "UPDATE $sql_table SET Sell_Price=? WHERE Bot_Id=?";
$id = $s_Bot_Id;
$stmt = $conn->prepare($sql);
$stmt->bind_param('ss', $content, $id);
if ($stmt->execute()){
return $stmt->affected_rows;
$stmt->close();
}else {
echo "save not working";
}
}
if(isset($_POST['keys'])){
$content = $_POST['keys'];
$sql_table = "bot_items_db";
$sql = "UPDATE $sql_table SET `Keys_Price` = ? WHERE Bot_Id = ?;";
$id = $s_Bot_Id;
$stmt = $conn->prepare($sql);
$stmt->bind_param('ss', $content, $id);
if ($stmt->execute()){
return $stmt->affected_rows;
$stmt->close();
}else {
echo "save not working";
}
}
if(isset($_POST['refs'])){
$content = $_POST['refs'];
$sql_table = "bot_items_db";
$sql = "UPDATE $sql_table SET Refined_Price=? WHERE Bot_Id=?";
$id = $s_Bot_Id;
$stmt = $conn->prepare($sql);
$stmt->bind_param('ss', $content, $id);
if ($stmt->execute()){
return $stmt->affected_rows;
$stmt->close();
}else {
echo "save not working";
}
}
答案 0 :(得分:0)
您还应该在html上为它们添加一个ID,以获取您无法通过名称获取数据的数据
<form action="POST">
<td class="tg-yw4l" ><?PHP echo $_CONFIG['item_Id'];?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['item_Name'];?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['itemPicture'];?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['market_Value'];?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['bptf_Value'];?></td>
<td class="tg-yw4l" ><?PHP echo $_CONFIG['opskins_Value'];?></td>
<td class="tg-yw4l" ><input id="sell" name="sell" placeholder="<?PHP echo "$".$Sell_Price;?>" value="<?PHP echo $Sell_Price;?>"></td>
<td class="tg-yw4l" ><input id="keys" name="keys" placeholder="<?PHP echo $Keys_Price."K";?>" value="<?PHP echo $Keys_Price;?>"></td>
<td class="tg-yw4l" ><input id="refs" name="refs" placeholder="<?PHP echo $Refs_Price."R";?>" value="<?PHP echo $Refs_Price;?>"></td>
</form>