我正在尝试从一个表中显示两组数据。我正在为我的游戏制作商店,并且有一个数据库,其中列出了商店中口袋妖怪的口袋妖怪/价格/类型/ID。现在我几乎可以使用它了,它显示了商店中的所有口袋妖怪,它们下面都有一个购买按钮,但出于某种原因,无论你尝试购买什么口袋妖怪,它只会购买列表顶部的那个。我希望我解释得足够好,这是我的代码。
if ($_POST['A'] == '1' ) {
$token= mysql_real_escape_string($_POST['token']);
$tokenn = strip_tags($token);
$sql234 = "SELECT * FROM ticketshop";
$result2 = mysql_query("SELECT * FROM ticketshop");
while($row2 = mysql_fetch_array($result2)){
$sql23 = "SELECT * FROM users WHERE username='".$_SESSION['username']."')";
$result = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'");
while($row = mysql_fetch_array($result)){
echo "You have ".$row['ticket']." Tickets" ;
echo "<p></p>" ;
if (isset($_POST['slot1'])) {
if ($row['ticket'] >= $row2['price']) {
echo "You have bought ".$row2['pokemon']."" ;
mysql_query("UPDATE users SET ticket=ticket-".$row2['price']." WHERE username='".$_SESSION['username']."'")
or die(mysql_error());
mysql_query("INSERT INTO user_pokemon
(pokemon, belongsto, exp, time_stamp, slot, level, type) VALUES ('".$row2['pokemon']."','".$_SESSION['username']."', 100,'".time()."','0', '5', '".$row2['type']."' )")
or die(mysql_error());
} else {
echo "You can't afford ".$row2['pokemon']."";
}
}
}
}