从表中获取值

时间:2013-09-19 13:15:07

标签: mysql sql

我的表是这样的:

+----------+-----------+
| ind_type | Index_val |
+----------+-----------+
| pcount   |         7 |
| ncount   |        15 |
+----------+-----------+

我想得到count和noncount的值:

这有什么问题:

$p= $mysqli->query('SELECT Index_val FROM view_name where ind_type='pcount'');
   echo "$p";

2 个答案:

答案 0 :(得分:0)

$query = mysqli->query("SELECT * FROM db WHERE a = 'bob'");
foreach ($query->fetch_object() as $row) {
   echo $row->column1;
   echo $row->column2;
   echo $row->column3;
}

答案 1 :(得分:0)

$p= $mysqli->query("SELECT Index_val FROM view_name where ind_type='pcount'");
   while ($obj = $p->fetch_object()){echo $obj->Index_val;}

//使用此