Jump to content

Dynamic $result based on IF statement, Help please


Darkstars31

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.