MySQL 和 PHP - 如何显示字段值等于 x 的所有行?

2023-12-15

我有一个数据库表(ff_projections),其中包含以下字段:

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

我想要的是显示 Position = QB 的所有行。只有某些字段会出现在 虽然行。

像这样:

SELECT Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Overall_Pts, Total_Fantasy_Pts  FROM ff_projections WHERE Position = 'QB';

然后将结果显示在网页上的表格中。


<?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);
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MySQL 和 PHP - 如何显示字段值等于 x 的所有行? 的相关文章