Jump to content

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.

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.