Home > Backend Development > PHP Tutorial > php调用mysql数据解决思路

php调用mysql数据解决思路

WBOY
Release: 2016-06-13 13:12:19
Original
921 people have browsed it

php调用mysql数据
有他个mysql数据库 a123456
里面有一个表 team
表里面有些字段: id,title,now_number

怎么用php调用6条mysql数据里的id,title等数据,按now_number的大小排序。


新手学习。先谢谢了。

------解决方案--------------------
...
$sql = 'SELECT * FROM team order by now_number desc limit 0,6';
$res = mysql_query($sql);
while($row = mysql_fetch_array($res)){
echo "ID:".$row['id']." TT:".$row['title']."
";
}
------解决方案--------------------
....
$db = mysql_pconnect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());//链接数据库,参数分别为mysql的主机(localhost),用户名,密码
mysql_select_db('a123456') or die("Error conecting to db.");//选择数据库
$sql='select * from team order by now_number desc limit 0,6';
$result =mysql_query ($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$id=$row["id"];
$title=$row["title"];
....

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template