0
我有一個雙重搜索發生在腳本內。當它搜索一個玩家裝備時,它會帶上玩家UID並帶回該玩家的名字。唯一的問題是可能會有超過1個結果返回,它只會顯示帶有名稱的最後一個UID。當有更多的PHP/Mysql搜索返回只有1結果
$ip = "localhost";
$user = "******";
$pass = "*******";
$db = "hivemind";
$ill1 = $_POST['search'];
//Database Connection
$con = @mysql_connect("$ip:3316", "$user", "$pass")
or die(mysql_error());
//Select Database
$dbcon = @mysql_select_db($db, $con)
or die(mysql_error());
$sql = mysql_query("select PlayerUID, Inventory, Backpack from character_data where Inventory like '%$ill1%'");
while ($row = mysql_fetch_array($sql)) {
$puid = $row['PlayerUID'];
$inv = $row['Inventory'];
$back = $row['Backpack'];
?>
<html>
<body>
<table>
<tr>
<td><?php echo "$puid"; ?></td>
<td><?php echo "$inv"; ?></td>
<td><?php echo "$back"; ?></td>
</tr>
</table>
</body>
</html>
<?php }?>
<?php
//Database Connection
$con = @mysql_connect("$ip:3316", "$user", "$pass")
or die(mysql_error());
//Select Database
$dbcon = @mysql_select_db($db, $con)
or die(mysql_error());
$sql = mysql_query("select PlayerUID, PlayerName from player_data where PlayerUID like '%$puid%'");
while ($row = mysql_fetch_array($sql)) {
$puid2 = $row['PlayerUID'];
$plnm = $row['PlayerName'];
?>
<html>
<body>
<table>
<tr>
<td><?php echo "$puid"; ?></td>
<td><?php echo "$plnm"; ?></td>
</tr>
</table>
</body>
</html>
}
就試了一下。它仍然只是從上面拉出最後一個PUID。 ' \t
\t不好意思,剛纔馬去編輯。
我剛試過。仍然只顯示1 '<? while($ row = mysql_fetch_array($ sql)){ \t $ puid2 = $ row ['PlayerUID']; \t $ plnm = $ row ['PlayerName']; \t \t \t \t \t \t \t回聲 「