Darkstars31 Posted September 12, 2007 Share Posted September 12, 2007 list($game, $type)= explode('|', $_POST[game]); if($type == "game"){$result = mysql_query( "SELECT TeamName,Owner,Wins,Loses FROM $dbname WHERE game_name = '$_POST[game]'")or die("SELECT Error: ".mysql_error()); } else { $result = mysql_query ( "SELECT user_id FROM $dbnametwo WHERE Teamname = '$_POST[game]'")or die("SELECT Error: ".mysql_error()); } $num_rows = mysql_num_rows($result); print "There are $num_rows Teams/Players.<P>"; print "<table width=600 border=1>\n<tr><td>Team Names/Players</td><td>Owner</td><td>W</td><td>L</td></tr> </table>"; print "<table width=600 border=1>\n"; while ($get_info = mysql_fetch_row($result)){ print "<tr>\n"; foreach ($get_info as $field) print "\t<td>$field</font></td>\n"; print "</tr>\n"; } print "</table>\n"; ?> <form method="POST"> <Select name="game"> <option></option> <?php while (list($game_selection) = mysql_fetch_row($find)) { $display = "<option value=\"$game_selection\">$game_selection</option>"; echo $display; while (list($team_selection) = mysql_fetch_row($find2)) { $display2 = "<option value=\"$team_selection\">*$team_selection</option>"; echo $display2; } } ?> </select> The IF statement at the top, always returns false, so I can never view the $result. I'm writing a simple Clan Ladder script. I want it to display the teams in the table based on user selection, thats the first $result. The Second Displays all the players on the team selected by the User from a Dropdown box. I can view the users on the teams, but i cant just view a master list of the teams. Help? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 12, 2007 Share Posted September 12, 2007 First, you need to use $_POST['game']; Secondly, what happens if you print $game before going into the loop. Why is it never == 'game'? Quote Link to comment Share on other sites More sharing options...
Darkstars31 Posted September 12, 2007 Author Share Posted September 12, 2007 so it should be: if($type == $_POST[game]) ? i think I've tried that do i need '$_POST[game]' instead? Not sure what you mean by printing $game before going to the loop? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 12, 2007 Share Posted September 12, 2007 That's not what I wrote...you need $_POST['game']. Before the if statement, add an echo or print to display the value of $game. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 12, 2007 Share Posted September 12, 2007 Change: list($game, $type)= explode('|', $_POST[game]); if($type == "game"){$result = mysql_query( "SELECT TeamName,Owner,Wins,Loses FROM $dbname WHERE game_name = '$_POST[game]'")or die("SELECT Error: ".mysql_error()); } else { $result = mysql_query ( "SELECT user_id FROM $dbnametwo WHERE Teamname = '$_POST[game]'")or die("SELECT Error: ".mysql_error()); } to: list($game, $type)= explode('|', $_POST['game']); if($type == "game") {$result = mysql_query( "SELECT TeamName,Owner,Wins,Loses FROM $dbname WHERE game_name = '$game'")or die("SELECT Error: ".mysql_error()); } else { $result = mysql_query ( "SELECT user_id FROM $dbnametwo WHERE Teamname = '$game'")or die("SELECT Error: ".mysql_error()); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.