Jump to content

php + mysql querry - too many results!


jpjsmith

Recommended Posts

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

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.