gpt4 book ai didi

php - 从我的数据库中选择多个 STEAMID

转载 作者:行者123 更新时间:2023-11-29 08:32:02 25 4
gpt4 key购买 nike

我需要一点帮助。我正在研究this页面,我想知道如何显示与昵称变量匹配的所有 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 '&nbsp;-&nbsp;';
echo $steamid2;
//echo '<br /><br />Last Recorded Steam Name:&nbsp;';
//echo '<br /><br />Current Steam Name:&nbsp;';
//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&nbsp;';
echo '"';
echo $nick;
echo '"';
echo '&nbsp;was not found in the database. Make sure you have correctly entered their nickname.';
}
?>
</body>
</html>

最佳答案

你需要循环:

while ($row1 = mysql_fetch_assoc($res1)) {
echo $row1['steamid']; // or store in an array etc.
}

关于php - 从我的数据库中选择多个 STEAMID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16314289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com