如何打印表的值及其字段名称

时间:2014-09-15 10:29:36

标签: php mysql

这是我的表:

student_name  father_name  sub1  sub2

  kunwar        Siyaram    20     40

我想打印表格的值及其字段名称:

Student_name : kunwar
father_name : Siyaram
sub1  : 20
sub2  : 40

查询

$select = mysql_query("select * from 2mcom where father_name='Siyaram'");

1 个答案:

答案 0 :(得分:1)

由于这是静态的,你可以这样做:

while (false != ($data = mysqli_fetch_array($result)))
  foreach ($data as $key => $value)
    echo "$key: $value<br />";