sql=  select count(*),style from uchome_pic where contract='anxin220091211002' group by style
count(*)  style 
1 客户签字照
1 室内环境
1 户口本
1 房产证
1 结婚证
2 身份证
1 门牌号我怎么把得到的结果循环赋给两个变量,谢谢!!!!

解决方案 »

  1.   


    $sql = "select count(*),style from uchome_pic where contract='anxin220091211002' group by style ";
    $result = mysql_query($sql);
    while($row = mysql_fetch_row($result)){
        echo $row[0]."  ".$row[1];
    }
      

  2.   

    $sql = "select count(*) num,style from uchome_pic where contract='anxin220091211002' group by style "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)){ echo $row['num']."  ".$row[1]; }
    sql里取个别名就可以了。
      

  3.   

    $sql = "select count(*),style from uchome_pic where contract='anxin220091211002' group by style ";
    $result = mysql_query($sql);
    while($row = mysql_fetch_row($result)){
        list($num[], $style[]) = $row;
    }
      

  4.   


    $sql = "select count(*),style from uchome_pic where contract='anxin220091211002' group by style ";
    $result = mysql_query($sql);
    while($row = mysql_fetch_row($result)){
        $a=$row[0];
        $b=$row[1];
        list($a,$b)= $row;
    }SQL 语句能这样写?select count(*),style from uchome_pic??
      

  5.   

    掉了注释了!$sql = "select count(*),style from uchome_pic where contract='anxin220091211002' group by style ";
    $result = mysql_query($sql);
    while($row = mysql_fetch_row($result)){
        $a=$row[0];
        $b=$row[1];
        //OR
        //list($a,$b)= $row;
    }