我有一个php文件,我希望用户从两个下拉列表中选择值,并在提交一些代码后执行。在测试之后我注意到,它读取了第一个echo,它通知用户已经选择了这两个特定值,但是所有其他代码(应该显示这两个值的连接)都不会执行。我觉得我很安全,但我觉得我需要一些推动力。以下是代码
<form method="GET" action="">
<table>
<tr><br /><br /><center><h2>Επιλέξτε τις ομάδες για τις οποίες θέλετε να δείτε το ιστορικό</h2><center><br /></tr>
<tr>
<td><i>Επιλογή 1ης ομάδας</i></td>
<td>
<select id="Team1" name="Team1"><option value="0">Καμία επιλογή</option>
<?php
global $wpdb;
$table = $wpdb->prefix . 'leagueengine_data';
$table2 = $wpdb->prefix . 'leagueengine_tournament_matches';
$teams = $wpdb->get_results("SELECT * FROM $table WHERE data_type = 'team' ORDER BY data_value ASC");
foreach ( $teams as $teams )
{ $team_id = $teams->id;
$team_name = $teams->data_value;
echo '<option value="'.$team_id.'">'.leagueengine_fetch_data_from_id($teams->id,'data_value') .'</option>';
}
$output .= '</div>';
?>
</select>
</td></tr>
<tr>
<td><i>Επιλογή 2ης ομάδας</i></td>
<td>
<select id="Team2" name="Team2"><option value="0">Καμία επιλογή</option>
<?php
global $wpdb;
$table = $wpdb->prefix . 'leagueengine_data';
$table2 = $wpdb->prefix . 'leagueengine_tournament_matches';
$teams2 = $wpdb->get_results("SELECT * FROM $table WHERE data_type = 'team' ORDER BY data_value ASC");
foreach ( $teams2 as $teams2 )
{ $team2_id = $teams2->id;
$team2_name = $teams2->data_value;
echo '<option value="'.$team2_id.'">'.leagueengine_fetch_data_from_id($teams2->id,'data_value') .'</option>';
}
$output .= '</div>';
?>
</select>
</td></tr>
</table>
<input type="submit" value="Αναζήτηση ιστορικού"><br />
</form>
<?php
$teamhome = mysql_real_escape_string($_GET['Team1']);
$teamaway = mysql_real_escape_string($_GET['Team2']);
$table2 = $wpdb-> prefix . 'leagueengine_tournament_matches';
echo '<div id="show">';
if (isset($_GET["Team2"])) {
echo "<center>Επιλέξατε να δείτε την προϊστορία μεταξύ των ομάδων";
echo '<b> '.leagueengine_fetch_data_from_id($teamhome, 'data_value').'</b>';
echo ' και <b>'.leagueengine_fetch_data_from_id($teamaway, 'data_value').'</b></center>';
$gbeet = $wpdb->get_var("SELECT count(*) FROM $table2 WHERE home_team_id = '$teamhome' AND away_team_id = '$teamaway' AND winner <> '' OR home_team_id = '$teamaway' AND away_team_id = '$teamhome' AND winner <> ''");
$home_team_wins = $wpdb->get_var("SELECT COUNT(*) FROM $table2 WHERE (home_team_id = '$teamhome' AND away_team_id = '$teamaway' or home_team_id = '$teamaway' AND away_team_id = '$teamhome') AND winner = '$teamhome'");
$away_team_wins = $wpdb->get_var("SELECT COUNT(*) FROM $table2 WHERE (home_team_id = '$teamhome' AND away_team_id = '$teamaway' or home_team_id = '$teamaway' AND away_team_id = '$teamhome') AND winner = '$teamaway'");
$homepnts1 = $wpdb->get_var("SELECT SUM(home_team_score) FROM $table2 WHERE home_team_id = '$teamhome' AND away_team_id = '$teamaway' AND winner <> ''");
$homepnts2 = $wpdb->get_var("SELECT SUM(away_team_score) FROM $table2 WHERE home_team_id = '$teamaway' AND away_team_id = '$teamhome' AND winner <> ''");
$homepnts= ($homepnts1) + ($homepnts2);
$awaypnts1 = $wpdb->get_var("SELECT SUM(home_team_score) FROM $table2 WHERE home_team_id = '$teamaway' AND away_team_id = '$teamhome' AND winner <> ''");
$awaypnts2 = $wpdb->get_var("SELECT SUM(away_team_score) FROM $table2 WHERE home_team_id = '$teamhome' AND away_team_id = '$teamaway' AND winner <> ''");
$awaypnts= ($awaypnts1) + ($awaypnts2);
$output .= '<br/><h2><center><b>Αναμετρήσεις ομάδων</b></center></h2>';
$output .= '<span><center><i>Οι ομάδες έχουν βρεθεί αντιμέτωπες <b>'.$gbeet.'</b> φορές.</i></center></span>';
$output .= '<table class="tournament_match_attributes">';
$output .= '<tbody><tr>';
$output .= '<th width="40%" style="text-align:center;"><b>'.leagueengine_fetch_data_from_id($teamhome, 'data_value').'</b></th>';
$output .= '<th width="20%"></th>';
$output .= '<th width="40%" style="text-align:center;"><b>'.leagueengine_fetch_data_from_id($teamaway, 'data_value').'</b></th>';
$output .= '</tr><tr>';
$output .= '<td>'.$home_team_wins.'</td>';
$output .= '<td><b>Νίκες</b></td>';
$output .= '<td>'.$away_team_wins.'</td>';
$output .= '</tr><tr>';
$output .= '<td>'.$homepnts.'</td>';
$output .= '<td><b>Πόντοι</b></td>';
$output .= '<td>'.$awaypnts.'</td>';
$output .= '</tr></tbody>';
$output .= '</table>';
$output .= '<table class="tournament_match_attributes">';
$games = $wpdb->get_results("SELECT * FROM $table2 WHERE home_team_id = '$teamhome' AND away_team_id = '$teamaway' AND winner <> '' OR home_team_id = '$teamaway' AND away_team_id = '$teamhome' AND winner <> '' ORDER BY match_date DESC;");
$output .= '<tbody><tr>';
$output .= '<th style="text-align:center;"><b>Τουρνουά</b></th>';
$output .= '<th style="text-align:center;"><b>Ημερομηνία</b></th>';
$output .= '<th style="text-align:center;"><b>Αγώνας</b></th>';
$output .= '<th style="text-align:center;"><b>Σκορ</b></th></tr>';
foreach($games as $games) {
$date_of_match = $games->match_date;
$dom = date("d/m/Y", strtotime($date_of_match));
$Ateam = leagueengine_fetch_data_from_id($games->home_team_id,'data_value') ;
$Bteam = leagueengine_fetch_data_from_id($games->away_team_id,'data_value') ;
$Ascore = $games->home_team_score;
$Bscore = $games->away_team_score;
$tourne = leagueengine_fetch_data_from_id($games->tournament_id,'data_value') ;
$output .= '<tr><td>' .$tourne. '</td>';
$output .= '<td>'.$dom. '</td>';
$output .= '<td>'.$Ateam.' - '.$Bteam.'</td>';
$output .= '<td>'.$Ascore.' - '.$Bscore.'</td>';
$output .= '</tr>';
}
$output .= '<tr></tbody>';
$output .= '</table>';
}
?>
答案 0 :(得分:0)
真的很抱歉没用,因为它似乎发布了。用echo:/
替换输出后,一切都解决了