我需要一点帮助。我正在处理这个页面,我想知道如何显示与 nick 变量匹配的所有 STEAMID 和昵称。我目前使用 LIKE = '%$nick%' 来查找匹配的昵称,但是如果两个玩家被称为 Sidewaykill,它只会显示一个,但我希望它显示所有。我并不关心它的外观,只要它显示所有匹配的玩家昵称和 STEAMID 即可。谢谢你。
<?php
//Get STEAMID from steamid variable
$nick = mysql_escape_string(stripslashes($_GET["nick"]));
$steamid = $_GET["steamid"];
?>
<!DOCTYPE html>
<html><head><title>Searching for a player steamid</title>
</head>
<body>
<?php
//Connect to database
$sqluser = "----";
$sqlpass = "----";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $sqluser, $sqlpass)
or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("versound_store",$dbhandle)
or die("Could not select database!");
//Attempt to find player SteamID
$sql1 = "SELECT steamid FROM `vxp_users` WHERE nick LIKE '%$nick%'";
$res1 = mysql_query($sql1) or trigger_error(mysql_error());
$row1 = mysql_fetch_assoc($res1);
$steamid2 = $row1['steamid'];
//Find latest recorded Nickname
$sql2 = "SELECT nick FROM `vxp_users` WHERE steamid = '$steamid2'";
$res2 = mysql_query($sql2) or trigger_error(mysql_error());
$row2 = mysql_fetch_assoc($res2);
$nick23 = $row2['nick'];
if (!empty($steamid2)) {
//Write Info
echo $nick23;
echo ' - ';
echo $steamid2;
//echo '<br /><br />Last Recorded Steam Name: ';
//echo '<br /><br />Current Steam Name: ';
//echo $currentsteamname;
echo '<br /><br /><a href="http://versound.org/finder/steamidtoprofile.php?steamid=';
echo $steamid2;
echo '" target="_blank">Link to Steam Profile</a>';
}
else
{
echo 'The player ';
echo '"';
echo $nick;
echo '"';
echo ' was not found in the database. Make sure you have correctly entered their nickname.';
}
?>
</body>
</html>