如果SteamID等于MYSQL行,则为PHP

时间:2016-01-14 17:38:42

标签: php mysql if-statement

它无效。我在尝试如下。

$(document).ready(function() {
   $('#circle').hover(
      function() {    // mouseenter event equivalent in hover
      $('#intro').hide([2]);  
    },
    function() {      // mouseleave event equivalent in hover
      $('#intro').show([2]);
    });
});

以下是完整的代码段。

if (($row["steamid"]) == $steamprofile['steamid']){

我尝试了各种方法。

3 个答案:

答案 0 :(得分:0)

// Create connection
$conn = new mysqli("localhost", "root", "", "stackoverflow");
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
//assume 1
$steamprofile['steamid']=1;

// changes here single quote    
$eh = $steamprofile['steamid'];

$sql = "SELECT steamid FROM Main";

$result = $conn->query($sql);
if ($result->num_rows > 0) 
{
    // output data of each row
    while($row = $result->fetch_assoc()) 
{
        if (($row["steamid"]) == $steamprofile['steamid']){
echo "SteamID Is Equal and Created!";
}

    }
} else {
    echo "Nope?";
}

$conn->close();
?> 

输出是 SteamID是平等和创造的!

Mysql数据库------------ CREATE TABLE IF NOT NOT EXISTS mainsteamid int(11)NOT NULL,   name varchar(500)NOT NULL )ENGINE = InnoDB AUTO_INCREMENT = 3 DEFAULT CHARSET = latin1;

-

- 转储表main

的数据

INSERT INTO mainsteamidname)VALUES (1,' test1'), (2,' test2');

答案 1 :(得分:0)

我认为你的

$eh = $steamprofile[steamid];

应改为

$eh = $steamprofile['steamid'];

答案 2 :(得分:0)

评论:

尝试echo $ row [" steamid"])。" =="。 $ steamprofile [' steamid'];所以你可以打印并检查。 - Hardy Mathew

的工作。感谢。