php mysql行最大长度限制吗,Php插入并更新mysql,限制为三行

I have a php script that logs inputs from a form into a mysql database table. I need a reference to only the last three inputs. To avoid the table to get filled up with inputs i'm looking for a way to insert this data untill 3 rows are created, after which it has to update the existing rows so that the first one updates to the new input, the second one to the former first input and the third one to the former second input. How can i accomplish this?

What I have tried:

i tried:$q = "select value from inputs where userid = '$userid' and name = 'input' order by id desc";

$result = mysqli_query($conn, $q);for the first three rows i can use:

if(mysqli_num_rows($result) < 4) {

$q = "insert into inputs (userid,name,value) values ('$userid','input','$value')";

}after which it has to become:

else {

$q = "update inputs set value = '$value' where userid = '$userid' and name = 'input' limit 3";

}where it has to update all the successive rows

解决方案

q = "select value from inputs where userid = '

userid' and name = 'input' order by id desc";

result = mysqli_query(

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值