这句sql语句
select count(*) from ffed where Cwtype = '临时车位'
我放到数据库里面执行结果是2但用php获取
$sql2 ="select count(*) from ffed where Cwtype = '临时车位'";
$linshi=mysql_query($sql2);$linshi的值为Resource id #4请问应该如何获取
select count(*) from ffed where Cwtype = '临时车位'
我放到数据库里面执行结果是2但用php获取
$sql2 ="select count(*) from ffed where Cwtype = '临时车位'";
$linshi=mysql_query($sql2);$linshi的值为Resource id #4请问应该如何获取
解决方案 »
- php5.4 连接Sqlserver2008 咋整啊?折腾3天鸟、累死了。
- 问一个数组基础问题
- 怎讓textbox隱藏
- 求助:Fatal error: Call to a member function db_fetch_array()
- CSDN积分漏洞
- 求PHP中SQL查询语句一条
- 高手请进:功能和界面分离的问题
- 如何动态生成HTML文件?
- 请教有关$HTTP_POST_VARS上传文件的问题?
- php处理从数据库中调出来的图片,路径里面有这个图片、
- 在linux下用php连接sqlserver2005出现乱码
- 菜鸟百分求助,关于php页面莫名出现空白行的原因,如果能够完美解决,追加100分
$linshi=mysql_query($sql2);
$row = mysql_fetch_assoc($linshi);
echo $row['count'];//就是统计数字。也可以用mysql_num_rows()函数
$linshi=mysql_query($sql2);
$row = mysql_fetch_object($linshi);//返回对象数组!楼上的方法取法也一样的道理!
echo $row->count;//count就是统计数字。也可以用mysql_num_rows()函数!核心还是SQL语句。你没有as一下。
当然不用的话就直接用mysql_num_rows()取值
$countsql = "select count(*) as count from ffed where Cwtype = '临时车位'";
$count = $this->db->getOne($countsql);
echo $count;
function getOne($sql)
{
if (is_resource($sql)) {
$res = $sql;
} else {
$res = $this->execute($sql);
}
$row = pg_fetch_row($res);
pg_free_result($res);
return isset($row[0]) ? $row[0] : null;
}
$linshi=mysql_query($sql2);
$arr = mysql_fetch_array($linshi);
echo $arr[0];