jpjsmith Posted June 4, 2003 Share Posted June 4, 2003 with php, i am querrying a mysql database and getting too many resluts returned. when i should retrive one record i get back 30+ of the same record. i querried the db directly and get one result - i am POSITIVE one result is correct. this is my (rather long) sql statement: $sql = \"SELECT Batting.yearID, Batting.teamID, Batting.lgID, Batting.G, Batting.AB, Batting.R, Batting.H, Batting.2B, Batting.3B, Batting.HR, Batting.RBI, Batting.SB, Batting.CS, Batting.BB, Batting.SO, Batting.IBB, Batting.HBP, Batting.SH, Batting.SF, Batting.GIDP, Teams.name FROM Teams, Batting where Batting.teamID=Teams.teamID AND Batting.playerID =\'$playerID\' AND Batting.yearId = \'$year\' \"; i just don\'t see where i went worng! anyone have any ideas? (i added the spaces here just to make it eaiser to read) :?: :?: Link to comment https://forums.phpfreaks.com/topic/543-php-mysql-querry-too-many-results/ Share on other sites More sharing options...
shivabharat Posted June 4, 2003 Share Posted June 4, 2003 To me the query looks fine :roll: Can u put more of ur code? Link to comment https://forums.phpfreaks.com/topic/543-php-mysql-querry-too-many-results/#findComment-1829 Share on other sites More sharing options...
jpjsmith Posted June 4, 2003 Author Share Posted June 4, 2003 this is pretty much everything to do with the querry. its pretty basic and ive used this code several times with out any problems. i must be missing something! <? include(\'dbconnect.php\'); ?> <? $playerID = $_GET[\'playerID\']; $year = $_GET[\'year\']; $result = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $year = $row[\'yearID\']; $teamid = $row[\'Batting.teamID\']; $league =$row[\'lgID\']; $games=$row[\'G\']; $ab=$row[\'AB\']; (all the variables are here, i cut them out for the sake of brevity ) $batting_data .= \"<tr><td class=\'head\'><h3 class =\'head\'>Year</h3></td><td class=\'head\'><h3 class =\'head\'>Team</h3></td><td class=\'head\'><h3 class =\'head\'>League</h3></td><td class=\'head\'><h3 class =\'head\'>Games</h3></td><td class=\'head\'><h3 class =\'head\'>At Bats</h3></td> </tr>\"; (etc...) } ?> later on the page... <? echo \"$batting_data\"; ?> thanks for taking a look! Link to comment https://forums.phpfreaks.com/topic/543-php-mysql-querry-too-many-results/#findComment-1832 Share on other sites More sharing options...
jpjsmith Posted June 4, 2003 Author Share Posted June 4, 2003 i changed one line to $batting_data = \"<tr><td class=\'head\'><h3 class =\'head\'>Year</h3></td><td class=\'head\'><h3 class =\'head\'>Team</h3></td><td class=\'head\'><h3 class =\'head\'>League</h3></td><td class=\'head\'><h3 class =\'head\'>Games</h3></td><td class=\'head\'><h3 class =\'head\'>At Bats</h3></td> </tr> <tr><td><h3>$year</h3></td><td>... \"; i took out the \".\" after $batting_data before the = i guess it just didn\'t like it in this case. Link to comment https://forums.phpfreaks.com/topic/543-php-mysql-querry-too-many-results/#findComment-1834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.