如何在php中获取MS访问的sum()查询结果

时间:2021-08-29 23:34:21

How can i get the sum() query value in php?. I'm using MS Access DB.

如何在php中获取sum()查询值?我用的是MS Access DB。

My Code:

我的代码:

$sql="select sum(col1) from table1 where Id=$id";
$rs=odbc_exec($con,$sql);
odbc_fetch_row($rs);

Now i want to get the result of this query. How can i get it?

现在我想要得到这个查询的结果。我怎样才能得到它?

I tried like echo odbc_result($rs,"col1");

我尝试使用echo odbc_result($rs,“col1”);

But it gives me an error as odbc_result(): Field Present not found

但是它给了我一个错误,因为odbc_result():没有找到的字段。

Help me out...

帮帮我……

1 个解决方案

#1


2  

Try with -

试一试,

$sql="select sum(col1) as col_sum from table1 where Id=$id";

And access by -

和访问

echo odbc_result($rs,"col_sum");

#1


2  

Try with -

试一试,

$sql="select sum(col1) as col_sum from table1 where Id=$id";

And access by -

和访问

echo odbc_result($rs,"col_sum");