Select data question... Help!!

Table name = playerslist11
Table name2 = teams ( newsid is where the team id is found)

[php]// Connect to server and select databse
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect”);
mysql_select_db("$db_name")or die(“cannot select DB”);

$sql="SELECT * FROM $playerslist11,teams Where WHERE playerslist11.team = teams.teamnameseason AND teams. teamname = (SELECT teamname from teams WHERE newsid = " . $teamid . ") ";
$result=mysql_query($sql);

// Define $color=1
$color=“1”;

echo ‘

’;
while($rows=mysql_fetch_array($result)){

// If $color==1 table row color = #ebf0f6
if($color==1){
echo "

"; // Set $color==2, for switching to other color $color="2"; }

// When $color not equal 1, use this table row color
else {
echo "

"; // Set $color back to 1 $color="1"; }

}
echo ‘

".$rows['Team']." ".$rows['Name']." ".$rows['Salary']."
".$rows['Team']." ".$rows['Name']." ".$rows['Salary']."
’;
mysql_close();
?>[/php]

My select code is the issue. Im trying to pull the stats above from playerslist11 by the team code found in the “teams” table. Just cant seem to grab it. I have nothing showing with the code i have…

Help anyone?

Hi
Try to echo your query than copy it and paste in mysql and see whether you are getting the data as your expectation if yes than there is variable problem and if no than your query is wrong

Sponsor our Newsletter | Privacy Policy | Terms of Service