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']."<br />";
}
[解决办法]
....
$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"];
....