sql isn n New数据现有数据,误差
我正在使用此代码通过PHP插入SQL数据库中的
$sql="INSERT INTO $tbl_name(cid, instrument, otime, volume, oprice, type, ctime, cprice, commission, swap, profitloss)VALUES('$pcid', '$pinstrument', '$potime', '$pvolume', '$poprice', '$ptype', '$pctime', '$pcprice', '$pcommission', '$pswap', '$pprofitloss')";
所有代码互相插入的所有数据,这意味着插入的第一个记录是在表格的顶部,然后是第二个bellow等。等。当我删除一行时,问题出现了,也是通过PHP使用下面的代码,然后将新记录插入旧记录的位置,而不是表的底部。
$sql="DELETE FROM $tbl_name WHERE id='$id'";
I'm inserting data into my sql database through php using this code
$sql="INSERT INTO $tbl_name(cid, instrument, otime, volume, oprice, type, ctime, cprice, commission, swap, profitloss)VALUES('$pcid', '$pinstrument', '$potime', '$pvolume', '$poprice', '$ptype', '$pctime', '$pcprice', '$pcommission', '$pswap', '$pprofitloss')";
All data inserted came after each other, meaning first record inserted is at the top of table then second bellow it and etc. the problem came when I deleted a row, also through php using the code below, afterwards new records are inserted in the place of the old records, not at the bottom of the table.
$sql="DELETE FROM $tbl_name WHERE id='$id'";
Anybody knows why? attached more info about my databasepicture1 pciture2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
技巧
按子句订购是我正在使用的
,但是当我添加订单成为此过程时,
它可以根据需要工作。
归功于Barmar的提示
Order by clause is the trick
I was using
But when I added ORDER BY to become this
It worked as desired.
Credit to Barmar for the hint