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

该博客内容涉及使用SQL查询从数据库表(ff_projections)中筛选出位置为'QB'的球员数据,展示包括球员名字、所在队伍、传球码数、传球达阵、抄截次数、冲球码数、冲球达阵、总得分和幻想积分等关键字段。查询结果按传球码数降序排列,并计划在网页上以表格形式显示。
摘要由CSDN通过智能技术生成

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);

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值