mysql使用url参数从列中获取数据

时间:2018-04-18 21:47:44

标签: php mysqli

我从使用'USER'值的列中获取数据时遇到了一些问题。 我放置WHERE USER='$USER'代码无法执行

if (isset($_GET['USER']) &&isset($_GET['SCORE']) &&isset($_GET['VERSUS']) &&isset($_GET['TIMESTAMP']) &&isset($_GET['STATUS'])){
$USER = strip_tags(mysqli_real_escape_string($dblink, $_GET['USER']));//get data from column USER
$SCORE = strip_tags(mysqli_real_escape_string($dblink, $_GET['SCORE']));//get data from column SCORE
$VERSUS = strip_tags(mysqli_real_escape_string($dblink, $_GET['VERSUS']));//get data from column VERSUS
$TIMESTAMP = strip_tags(mysqli_real_escape_string($dblink, $_GET['TIMESTAMP']));//get data from column TIMESTAMP
$STATUS = strip_tags(mysqli_real_escape_string($dblink, $_GET['STATUS']));//get data from column STATUS
$sql = ("SELECT * FROM `record` WHERE USER='$USER';");//choose userdata table from database where column USER
$result = $dblink->query($sql);

$result= $dblink->query("SELECT * FROM `record` WHERE USER='$USER' ORDER BY `record`.`TIMESTAMP` DESC;");

if (mysqli_num_rows($result) > 0) {
while($row=mysqli_fetch_array($result)){
echo $row['USER'] . "|" . $row['VERSUS'] . "|" . $row['STATUS'] . "|";

// close while loop 
}
} else {
    echo "0 results";
}
}

显示mysql数据的网址

xx.xxx.com/x/xxxx.php?USER=JBROWN

0 个答案:

没有答案