newbie with a question...

Hey gents, im fairly new to this but have made some progress. I have something im working on and in the end result i want specific information from a specific team to be showen from a db. Can anyone look at this code and see what i may have done… Much thanks in advance…

$db_name=“vhamainsite”; // Database name
$tbl_name=“playerslist11”; // Table name

// 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 $tbl_name”;
$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['Num']." ".$rows['Name']." ".$rows['Pos']." ".$rows['Salary']." ".$rows['Contract']." ".$rows['Status']." ".$rows['11/12Salary']." ".$rows['12/13Salary']." ".$rows['13/14Salary']." ".$rows['Protected']." ".$rows['Rookie']."
".$rows['Num']." ".$rows['Name']." ".$rows['Pos']." ".$rows['Salary']." ".$rows['Contract']." ".$rows['Status']." ".$rows['11/12Salary']." ".$rows['12/13Salary']." ".$rows['13/14Salary']." ".$rows['Protected']." ".$rows['Rookie']."
’;
mysql_close();
?>

I need all players from the same team to show along with there stats there.

Thanks again, it helps me better understand…

You didn’t say what the problem was.

Sorry… Ive been so frustrated with it… The select line is where my problem is… Still trying to learn it. I am looking to show the stats from one specific team using there team id. Here is my url…

http://www.virtualhockeyassociation.com/teampagesalary.php?id=13

Anything else let me know… Thanks a bunch…

table name = playerslist11
table name “teams” is where the team id is located.

This
[php]$sql=“SELECT * FROM $tbl_name”;[/php]
should be this
[php]$sql=“SELECT * FROM ‘$tbl_name’”;[/php]

Yea i found that issue but it still isnt showing the info by id…

Any other thoughts?

You have to change the query as you want the data with one id. So your query should be like this.

select * from table_name where id=$id

where $id is the value of team id

Thanks . I got it…

:slight_smile:

you are welcome

Sponsor our Newsletter | Privacy Policy | Terms of Service