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? Link to comment https://forums.phpfreaks.com/topic/68941-dynamic-result-based-on-if-statement-help-please/ 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'? Link to comment https://forums.phpfreaks.com/topic/68941-dynamic-result-based-on-if-statement-help-please/#findComment-346541 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? Link to comment https://forums.phpfreaks.com/topic/68941-dynamic-result-based-on-if-statement-help-please/#findComment-346548 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. Link to comment https://forums.phpfreaks.com/topic/68941-dynamic-result-based-on-if-statement-help-please/#findComment-346549 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()); } Link to comment https://forums.phpfreaks.com/topic/68941-dynamic-result-based-on-if-statement-help-please/#findComment-346604 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.