php - 在php的数据库中的同一行中插入具有相同名称的表单输入值
问题描述
我在这里多次尝试将输入输入数据库。如您所见,条目是可变的。像这样的代码
<?php
$WALLETS_query = $db->query("SELECT * FROM wallets");
$WALLET_EXIST = $WALLETS_query->num_rows;
while ($WALLET = $WALLETS_query->fetch_assoc() ) {
$table_name = $WALLET['table_name'];
$wallet_name = $WALLET['wallet_name'];
$wallet_currency = $WALLET['wallet_currency'];
$wallet_currency_symbole = $WALLET['wallet_currency_symbole'];
$wallet_instructions = $WALLET['wallet_instructions'];
$add_date = $WALLET['add_date'];
$status = $WALLET['status'];
echo "
<div class='col-md-12 col-lg-12'>
<div class='form-group'>
<label class='form-label'> Price in $wallet_currency ($wallet_currency)</label>
<input type='number' class='form-control' name='game_price[$wallet_currency][]' id='game_$wallet_currency' placeholder='Price in $wallet_currency_symbole '>
</div>
</div>";
}
?>
我必须注意,输入的数量与表(钱包)中的条目数量有关,因此输入是可变的,名称也是如此,我想将输入值正确输入到数据库中。
// Add New Game
if (isset($_POST['add_new_game'])) {
$GAME_selected_game_type = $_POST['selected_game_type'];
$GAME_game_title = $_POST['game_title'];
$GAME_game_quantity = $_POST['game_quantity'];
$GAME_game_price = $_POST['game_price'];
$Date = date('Y-m-d');
$wallets = Query_db_table("SELECT * FROM wallets");
foreach($wallets as $wallet){}
$DATA = array(
'type' => $GAME_NAME,
'name' => $Date,
'price' => $GAME_game_price,
'status' => 1
);
//Insert Information to database
dbRowInsert("games",$DATA);
header("Location: $_SERVER[PHP_SELF]");
}else{
}
太感谢了
解决方案
推荐阅读
- python - selenium 浏览器用keyboard.read_key() 关闭
- docker - gitlab ci 错误 /bin/sh: eval: line 138: docker: not found
- javascript - 即使在两个 async/await 块内,firebase 函数中的 Axios 也会返回待处理的 Promise
- javascript - chrome 扩展调用特定功能
- javascript - 在抛出错误“未定义的ng”的元素之间共享角度库
- sql-server - 我收到 SSIS 错误代码:对连接管理器 Oracle 连接管理器的 AcquireConnection 方法调用失败,错误代码为 0x80004005
- python - 如何在 Kaplan Meier 曲线上显示置信区间
- python - 通过python计算日志文件中两种模式之间的持续时间
- c# - 加载特定时间的 Lib.Vlc 播放器
- ios - 在心理设备 Flutter 上使用 NFC 和 Flutter