MySQLI和Select 1(MySQLI and Select 1)
从数据库获取数据时,我的if语句没有按预期工作,即使我在该用户的数据库中有$ badgename,我得到“你得到一个新的徽章”。 但它没有穿上它。
我是MySQLI的新手,所以这可能是我错过的东西......
$numberofposts=$row['posts']; $userid = $_SESSION['userid']; $badgename = "Legend"; if($numberofposts >= 10){ $SQL = $mysqli->query("SELECT 1 FROM `badges` WHERE `mid`='$userid' AND 'badge' = '$badgename'"); $num = $SQL->num_rows; if($num > 0){ echo "You got a new badge"; $mysqli->query("INSERT INTO badges ('mid', 'badge') VALUES ('$userid', '$badgename')"); } else { echo "You already have this badge"; }
谢谢。
When getting data from the databas my if statement isn't working as expected, even though I have the $badgename in the database for that user I got "You get a new badge". But it dosen't put it on.
Im new to MySQLI so it's probably something I missed...
$numberofposts=$row['posts']; $userid = $_SESSION['userid']; $badgename = "Legend"; if($numberofposts >= 10){ $SQL = $mysqli->query("SELECT 1 FROM `badges` WHERE `mid`='$userid' AND 'badge' = '$badgename'"); $num = $SQL->num_rows; if($num > 0){ echo "You got a new badge"; $mysqli->query("INSERT INTO badges ('mid', 'badge') VALUES ('$userid', '$badgename')"); } else { echo "You already have this badge"; }
Thanks.
原文:https://stackoverflow.com/questions/21976406
最满意答案
正确。 Windows Mobile中的(X)按钮称为“智能最小化”按钮,仅最小化窗体。 将Form的MinimizeBox属性设置为false,它将更改为(OK),这将关闭Form(并引发事件)。
关于为什么会发生这种情况的血腥细节, 请阅读此内容 。
Correct. The (X) button in Windows Mobile is called the "Smart Minimize" button and only minimizes the Form. Set the Form's MinimizeBox property to false and it will change to (OK) which will close the Form (and raise the event).
For the gory details as to why this happens, read this.
相关问答
更多-
FormClosingEventArgs事件参数类有一个枚举来告诉表单关闭的原因。 https://msdn.microsoft.com/en-us/library/system.windows.forms.closereason(v=vs.110).aspx Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.Closing If Not appClos ...
-
您可以覆盖OnFormClosing来执行此操作。 只要小心你不要做任何意外的事情,因为点击“X”关闭是一个很好理解的行为。 protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); if (e.CloseReason == CloseReason.WindowsShutDown) return; // Confirm user wants to close ...
-
Qt:如何处理用户按“X”(关闭)按钮的事件?(Qt: How do I handle the event of the user pressing the 'X' (close) button?)[2022-03-11]
如果你有一个QMainWindow你可以重写closeEvent方法。 #includevoid MainWindow::closeEvent (QCloseEvent *event) { QMessageBox::StandardButton resBtn = QMessageBox::question( this, APP_NAME, tr ... -
(X)按钮不是关闭按钮,它是一个智能最小化按钮,您不能直接挂钩它(您可能会得到一个已禁用的事件,但您无法取消该按钮)。 您可以将Form的MinimizeButton属性更改为false,并将其更改为(ok)按钮,您可以处理该按钮(如Petros指出的那样)。 您可以使用IMessageFilter或表单的子类来挂钩它的WinProc以获取最小化事件。 也可以看看: 如何检测智能最小化 皇帝没有接近 子类化CF应用程序 用本机回调子类化一个按钮 The (X) button is not a Close b ...
-
我没有运行Windows 8,所以我无法测试它,但你可以检查是否已经使用jQuery按下按钮。 例如:Html代码: jQuery的: var alreadySent = false; $(document).ready(function() { $("#myButton").click(function(event) { event.preventDefault(); if (!alreadySent) ...
-
在Windows窗体中单击关闭按钮时的事件处理程序(An Event Handler when Close Button is clicked in windows form)[2022-08-05]
如果您使用的是.ShowDialog(),则可以通过DialogResult属性获取结果。 public void newWindow() { Form1 nw = new Form1(); DialogResult result = nw.ShowDialog(); //do something after the dialog closed... } 然后在Form1上的单击事件处理程序中: private void buttonOk_Click(object sender, ... -
正确。 Windows Mobile中的(X)按钮称为“智能最小化”按钮,仅最小化窗体。 将Form的MinimizeBox属性设置为false,它将更改为(OK),这将关闭Form(并引发事件)。 关于为什么会发生这种情况的血腥细节, 请阅读此内容 。 Correct. The (X) button in Windows Mobile is called the "Smart Minimize" button and only minimizes the Form. Set the Form's Mini ...
-
您遇到了KeyListeners的常见问题 - 缺乏组件焦点。 要使KeyListener起作用,被侦听的组件必须既可以聚焦又具有用户焦点,对于您的应用程序而言,这两者都不是。 快速解决方法是通过setFocusable(true)使您的JPanel可聚焦,然后通过requestFocusInWindow()获得焦点。 public DrawingPanel() { addKeyListener(this); setFocusable(true); requestFocusInWindow(); ...
-
Windows Mobile中的非关闭关闭按钮(使用Qt开发)(Nonclosing close button in Windows Mobile ( developed with Qt))[2021-11-27]
“Smart Minimize”按钮由创建Windows时通常设置的样式位来处理 - 具体为WS_NONAVDONEBUTTON。 对于CF应用程序,可通过将MinimizeButton属性设置为false来控制此应用程序。 在C / C ++中,通过在调用CreateWindow时添加该位或之后设置位来完成(直接或者如Shane所示,通过SHDoneButton)。 Qt显然正在创建一个Window,所以在这个过程中你需要改变样式位。 我不是一个Qt开发人员,所以我不知道在这个框架中是如何完成的。 The ... -
这是因为Esc键在Firefox中触发后会立即停止刷新。 使用setTimeout以便在事件完成冒泡后执行location.reload() 。 jQuery(document).keydown(function (event) { if (event.keyCode == 27) { setTimeout(closeVideoPopup, 0); } }); 小提琴 或者更好,只需调用event.preventDefault()以便Esc键不会取消页面重新加载: jQue ...