Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用函数调用 mysql 数据库中有 10 列。列的名称是;videoSec1、videoSec2、videoSec3、videoSec4等。语句可以用变量设置吗?我想出的例子不起作用。
$stmt1 = $mysqli->prepare('UPDATE users SET ("videoSec"+index)=? WHERE userID=?); $stmt1->bind_param('ii',$secc,$userID); $stmt1->execute();
您必须创建另一个表videoSec,由 2 列组成:index和userID
videoSec
index
userID
而不是更新它,只需添加或删除行:
$stmt = $mysqli->prepare('INSERT INTO videoSec SET index=?, userID=?'); $stmt->bind_param('ii',$secc,$userID); $stmt->execute();
这就是关系数据库的工作方式。