I have a database table (ff_projections) that contains the following fields:
ID Player Position Team Pass_Yds Pass_TDs Int_Thrown Rush_Yds Rush_TDs Rec_Yds Rec_TDs Receptions Fumbles Extra_Pts FG Sacks Int_Caught Def_TD ST_TD Shutouts Overall_Pts Total_Fantasy_Pts
What I want is to display all rows where Position = QB. Only certain fields would appear in
the rows though.
Like this:
SELECT Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Overall_Pts, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'QB';
and then display the results in a table on the web page.
解决方案<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Overall_Pts, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'QB' ORDER BY Pass_Yds DESC;");
while($row = mysql_fetch_array($result))
{
echo $row['Player'];
echo $row['Team'];
....
}
mysql_close($con);
?>