shmeeg Posted June 6, 2010 Share Posted June 6, 2010 ok so I guess I'm not too good at this here's my code: <?php echo $_GET["type"]; ?> > <?php if $_GET["type")=="player" echo $row["name"]; elseif $_GET["type"]=="team" echo $row["team"]; ?> I dont usually use if and elseif statements, infact, it's the first time I ever have tried it. What I'm trying to do is allow users to see where they are, at the top of the page it should look a little something like soccerdb > Statistics > Player(if type=player)/Team(if type=team) > player name/team name thanks in advance. Link to comment https://forums.phpfreaks.com/topic/204010-parse-error-using-if-and-elseif/ Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2010 Share Posted June 6, 2010 Since there are only 2 options, an "else if" isn't really necessary. "Else" will work just fine. <?php if( $_GET["type")=="player" ) { echo $row["name"]; } else { echo $row["team"]; } ?> Link to comment https://forums.phpfreaks.com/topic/204010-parse-error-using-if-and-elseif/#findComment-1068525 Share on other sites More sharing options...
shmeeg Posted June 6, 2010 Author Share Posted June 6, 2010 that solution is also giving me syntax errors. <br />soccerdb > statistics > <?php echo $_GET["type"]; ?> > <?php if( $_GET["type")=="player" ) { echo $row["name"]; } else { echo $row["team"]; } ?> that's the whole piece of code that I have now, error is on line 3 and 5? EDIT: found the error in that one, thanks! it works Link to comment https://forums.phpfreaks.com/topic/204010-parse-error-using-if-and-elseif/#findComment-1068528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.