基本上,这段代码列出了“可用”挑战,每个列表complete = 0
都有一个接受按钮。submit
到目前为止,我一次只能列出一项,因为列出的多个按钮无法识别匹配 ID$echo
任何人都可以查看我的代码,看看我是否可以进行任何更改,以便我可以更改desc limit 10
谢谢1
。
$query = mysql_query("SELECT `create_id` ,`value`, `player1`, `match_id` FROM `multiplayer` WHERE `complete` = 0 ORDER BY `value` DESC LIMIT 1");
echo '<table>';
while($rowtwo = mysql_fetch_array($query)){
$format_coins = number_format($rowtwo['value']);
$value = $rowtwo['value'];
$create_player = $rowtwo['player1'];
$echo = $rowtwo['match_id'];
$create_id = $rowtwo['create_id'];
$button = '<form action="multiplayer.php" method="POST"><input type="submit" name="'.$echo.'" value="Accept"></form>';
///$button = '<a href="match/'.$echo.'.php">Accept</a>';
echo '<tr>
<td><font size="2" face="Lucida Sans Unicode"><strong>'.$rowtwo['player1'].'</strong> has wagered '.$format_coins.'M/Gp '.$button.'</td>
</tr>';
}
echo '</table>';
if (isset($_POST[''.$echo.''])) {
if ($user_data['coins'] >= $value) {
if ($user_data['user_id'] == $create_id) {
echo 'You can\'t play yourself.';
} else {
$betadd = $user_data['bets'] + 1;
mysql_query("UPDATE `users` SET `bets` = $betadd WHERE `user_id` = $user_id");
$rand1 = rand(1, 5);$rand2 = rand(1, 5);$rand3 = rand(1, 5);$rand4 = rand(1, 5);$rand5 = rand(1, 5);$rand6 = rand(1, 5);$rand7 = rand(1, 5);$rand8 = rand(1, 5);$rand9 = rand(1, 5);$rand10 = rand(1, 5);
echo '<font size="2"><strong>You\'ve</strong> planted : <br></font>';
if ($rand1 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand1 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand1 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand1 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand1 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand2 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand2 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand2 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand2 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand2 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand3 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand3 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand3 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand3 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand3 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand4 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand4 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand4 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand4 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand4 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand5 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand5 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand5 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand5 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand5 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
$userscore = counting(array($rand1, $rand2, $rand3, $rand4, $rand5));
echo '<br>';
echo '<font size="2"><strong>'.$create_player.'</strong> planted : <br></font>';
if ($rand6 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand6 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand6 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand6 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand6 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand7 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand7 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand7 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand7 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand7 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand8 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand8 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand8 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand8 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand8 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand9 === 1) { echo '<img src="images/Red_flowers.png">';} else if ($rand9 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand9 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand9 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand9 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
if ($rand10 === 1){ echo '<img src="images/Red_flowers.png">';} else if ($rand10 === 2) {echo '<img src="images/Blue_flowers.png">';} else if ($rand10 === 3) {echo '<img src="images/Yellow_flowers.png">';} else if ($rand10 === 4) {echo '<img src="images/Orange_flowers.png">';} else if ($rand10 === 5) {echo '<img src="images/Flowers_(pastel).png">';}
//echo '<br>';
$hostscore = counting(array($rand6, $rand7, $rand8, $rand9, $rand10));
mysql_query("UPDATE `multiplayer` SET `rand1` = $rand1 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand2` = $rand2 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand3` = $rand3 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand4` = $rand4 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand5` = $rand5 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand6` = $rand6 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand7` = $rand7 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand8` = $rand8 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand9` = $rand9 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `rand10` = $rand10 WHERE `match_id` = $echo");
echo '<br>';
echo '<br>';
if ($userscore > $hostscore) {
echo 'You win';
$username = $user_data['username'];
$userid = $user_data['user_id'];
mysql_query("UPDATE `users` SET `multi` = 0 WHERE `user_id` = $create_id");
mysql_query("UPDATE `multiplayer` SET `complete` = 1 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score1` = $hostscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score2` = $userscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `player2` = '$username' WHERE `match_id` = $echo");
$coins = $user_data['coins'] + $value;
mysql_query("UPDATE `users` SET `coins` = $coins WHERE `user_id` = $userid");
} else if ($userscore == $hostscore) {
echo 'You\'ve Tied';
$username = $user_data['username'];
mysql_query("UPDATE `users` SET `multi` = 0 WHERE `user_id` = $create_id");
mysql_query("UPDATE `multiplayer` SET `complete` = 1 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score1` = $hostscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score2` = $userscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `player2` = '$username' WHERE `match_id` = $echo");
$hostcoins = mysql_query("SELECT `coins` FROM `users` WHERE `user_id` = $create_id");
$hostpayback = $hostcoins + $value;
mysql_query("UPDATE `users` SET `coins` = $hostpayback WHERE `user_id` = $create_id");
} else if ($userscore < $hostscore) {
echo 'You\'ve Lost.';
$username = $user_data['username'];
$userid = $user_data['user_id'];
mysql_query("UPDATE `users` SET `multi` = 0 WHERE `user_id` = $create_id");
mysql_query("UPDATE `multiplayer` SET `complete` = 1 WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score1` = $hostscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `score2` = $userscore WHERE `match_id` = $echo");
mysql_query("UPDATE `multiplayer` SET `player2` = '$username' WHERE `match_id` = $echo");
$hostcoins = mysql_query("SELECT `coins` FROM `users` WHERE `user_id` = $create_id");
$hostpayback = $hostcoins + ($value * 2);
mysql_query("UPDATE `users` SET `coins` = $hostpayback WHERE `user_id` = $create_id");
$coins = $user_data['coins'] - $value;
mysql_query("UPDATE `users` SET `coins` = $coins WHERE `user_id` = $userid");
}
}
} else { echo 'You can\'t afford to enter this match.'; }
}
这里
///$button = '<a href="match/'.$echo.'.php">Accept</a>';
echo '<tr>
<td><font size="2" face="Lucida Sans Unicode"><strong>'.$rowtwo['player1'].'</strong> has wagered '.$format_coins.'M/Gp'. $button = '
<form action="multiplayer.php" method="POST">
<input type="radio" name="$echo" value="$echo">
';.' '.$button.'</td>
</tr>';
}
echo '</table>';
echo '<input type="submit" name="submit" value="Accept"></form>';
if (isset($_POST['submit'])) {
if (isset($_POST['$echo'])){
echo $echo;
}