更新SQL表的行(Update rows of a SQL table)
我有一个名为'status'的列表。 'status'的defaut值为0.我想在使用后将值更新为'1'。 我基本上想检查状态是否为0,如果是,则执行操作然后将值更改为1。
这是代码。 除了0的值没有变为1之外,所有的工作都很完美。我是新手所以也许是一个非常基本的错误:(
<?php $sql = "SELECT number, status FROM summonerid"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $SummonerID = $row["number"]; $status = $row["status"]; if($status=='0'){ $recentgames=$lol->getRecentGames($SummonerID); $MatchID1=$recentgames->games[0]->gameId; $sql = "INSERT INTO matchid (number) SELECT * FROM (SELECT '$MatchID1') AS tmp WHERE NOT EXISTS (SELECT number FROM matchid WHERE number = '$MatchID1') LIMIT 1;"; $sql = "UPDATE summonerid SET status='1' WHERE status='0';"; // THIS IS THE PART THAT DOES NOT WORK WELL } } } ?>
任何帮助将受到高度赞赏
I have a table with a column called 'status'. The defaut value of 'status' is 0. I want to update the value to '1' after using it. I basically want to check if the status is 0, if it is, do an operation and then change the value to 1.
Here is the code. All works perfectly except that the value of 0 is not changed to 1. I am a novice so maybe is a very basic mistake :(
<?php $sql = "SELECT number, status FROM summonerid"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $SummonerID = $row["number"]; $status = $row["status"]; if($status=='0'){ $recentgames=$lol->getRecentGames($SummonerID); $MatchID1=$recentgames->games[0]->gameId; $sql = "INSERT INTO matchid (number) SELECT * FROM (SELECT '$MatchID1') AS tmp WHERE NOT EXISTS (SELECT number FROM matchid WHERE number = '$MatchID1') LIMIT 1;"; $sql = "UPDATE summonerid SET status='1' WHERE status='0';"; // THIS IS THE PART THAT DOES NOT WORK WELL } } } ?>
Any help would be highly appreciated
原文:https://stackoverflow.com/questions/30220442
最满意答案
回头看IfEqual的文档...你切换了var和value。
; Copy cell var := clipboard sleep, 1000 WinActivate, doesntmatter - Internet Explorer IfEqual, var, 30684047 { sleep, 500 Send, inform } else { msgbox, nope } return
除非您想在剪贴板稍后更改后重新使用该值,否则实际上不需要将剪贴板的值保存到其他变量中。 所以上面也可以是:
WinActivate, doesntmatter - Internet Explorer If (clipboard = "30684047") { sleep, 500 SendInput, inform } else msgbox, nope return
Look back at the documentation for IfEqual...you switched var and value.
; Copy cell var := clipboard sleep, 1000 WinActivate, doesntmatter - Internet Explorer IfEqual, var, 30684047 { sleep, 500 Send, inform } else { msgbox, nope } return
There's really no need to save off the value of clipboard to a different variable unless you're wanting to re-use that value after clipboard has later changed. So the above could also be:
WinActivate, doesntmatter - Internet Explorer If (clipboard = "30684047") { sleep, 500 SendInput, inform } else msgbox, nope return
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
这个程序不要求数组中的预定5个数字?(This program isn't asking for the predetermined 5 numbers from the array? [closed])[2022-05-30]
int largest_number(int score[], int max) { for (int i=1; i<5; i++) { cin >> score[i]; if(score[i] > max) max=score[i]; return (max); //whoops! it's inside the for loop } } 你把你的回归置于for循环中,这意味着无论你只进入score[1] ... -
2个剪贴板ahk脚本(2 clipboards ahk script)[2021-09-11]
我认为你的问题属于学术性质。 如果没有,我推荐已经有很多剪贴板管理器中的一个。 这是一个有评论的解决方案: lastClip := "" bufferedClip := Clipboard OnClipboardChange("clipChangeHandler") ; Note that the ALT key can change focus, better use WIN+V #v:: ; Since we temporarily switch Clipboard's contents, ... -
你可以使用正则表达式和match()方法(未经测试) var reg = new RegExp("^"+TheWordToCheck+"\\s\\d$") if (!TheObject['SomeProperty'].match(reg) {... 小提琴 You could use a regex and the match() method (untested) var reg = new RegExp("^"+TheWordToCheck+"\\s\\d$") if (!TheObject['S ...
-
您可能会选择相同的号码两次。 与...一起 array1 = [1] array2 = [2] 你会得到2 == 1 + 1 。 为了避免这种情况,你可以使用Array#combination : array1.combination(2).select { |x, y| array2.include? x + y }.each do |x, y| # do something with x, y and x + y end You might pick the same number twice. ...
-
回头看IfEqual的文档...你切换了var和value。 ; Copy cell var := clipboard sleep, 1000 WinActivate, doesntmatter - Internet Explorer IfEqual, var, 30684047 { sleep, 500 Send, inform } else { msgbox, nope } return 除非您想在剪贴板稍后更改后重新使用该值,否则实际上不需要将剪贴板的值保存到其 ...
-
将选项 B0附加到热点字符串可防止删除以前输入的短语,因此您不必再次发送: :B0:if:: MsgBox Use two equal signs to check for equality! Return Attaching the option B0 to a hotstring prevents it from removing the previously typed phrase, so you don't have to re-send if again: :B0:if:: ...
-
所以我玩弄了它,并且让PrevSlot成为一个全局变量,并删除了变量周围的%。 So I played around with it and I made PrevSlot a global variable and removed the % around the variable.
-
你应该使用UIPasteboard类。 if let value = UIPasteboard.general.string { // there is value in clipboard } else { // clipboard is empty } You should use UIPasteboard class. if let value = UIPasteboard.general.string { // there is value in clipboard } e ...
-
AHK在不使用#Include Subroutines.ahk的情况下加载热字符串(AHK Load hotstrings without using #Include Subroutines.ahk)[2022-03-26]
演示使用映射到动态值的热键 ; Replace hash values with whatever method you use to decrypt your hotstrings decrypted := {abc: "alpha", def: "beta"} ::abc:: Send % decrypted["abc"] return ::def:: Send % decrypted["def"] return 当您键入“abc”时,会出现“alpha” Demonstrates ...