问题是这样的:如果只是用表格输出数据表中的数据那就太简单了,关键是我的数据表中有一个“组号”的字段,名为group_id.每8人一组,组号自动添加上去的,字段值为1、2、3...组。我想得到每一组的数据,而每一组都是以独立的表格呈现的(即第一组有一个表格,表格里记录第一组的数据;第二组有一个表格,表格里有第二组的数据;以此类推)
不知道有没有说清楚,在线等

解决方案 »

  1.   

    我现在得到的效果图如下:学号         姓名     性别 班级 项目名称  参赛编号 组号
    2009052789 0003     男   2009电子商务 100米   0003 1
    2009052795 狂了房     男   2009旅游管理 100米   0009         1
    2009052794 uisfkjio    男   2009商英二班 100米   0008         1
    2009052793 fvlsdjflj   男   2009酒店管理 100米   0007         1
    2009052792 sdfksjdfk   男   2009旅游管理 100米   0006         1
    2009052791 的份上     男   2009电子商务 100米   0005         1
    2009052790 timesima    男   2009电子商务 100米   0004         1
    2009052788 伍龙君     男   2009电子商务 100米   0002         1
    2009051822 李鸿君     男   2009电子商务 100米   0013         2
    2009052797 花费空间看  男   2009旅游管理 100米   0012         2看到最后一列的组号了吧?所有的组号的数据都在一个表格里显示,现在我想要的效果是每个组号都有一个表格,效果如下:
    第一组:
    学号         姓名     性别 班级 项目名称  参赛编号 组号
    2009052789 0003     男   2009电子商务 100米   0003 1
    2009052795 狂了房     男   2009旅游管理 100米   0009         1
    2009052794 uisfkjio    男   2009商英二班 100米   0008         1
    2009052793 fvlsdjflj   男   2009酒店管理 100米   0007         1
    2009052792 sdfksjdfk   男   2009旅游管理 100米   0006         1
    2009052791 的份上     男   2009电子商务 100米   0005         1
    2009052790 timesima    男   2009电子商务 100米   0004         1 第二组:
    学号         姓名     性别 班级 项目名称  参赛编号 组号
    2009051822 李鸿君     男   2009电子商务 100米   0013         2
    2009052797 花费空间看  男   2009旅游管理 100米   0012         2每8人一组,不足8人的为一组
      

  2.   

    参考以下写法:
    $arr=array(
    array('id'=>'2009052788' ,'name'=>'b', 'group'=>1),
    array('id'=>'2009051822' ,'name'=>'c', 'group'=>2),
    array('id'=>'2009052788' ,'name'=>'a', 'group'=>1),
    array('id'=>'2009052797' ,'name'=>'d', 'group'=>2)
    );foreach($arr as $v)  $t[$v['group']][]=$v;
    foreach($t as $v){
             echo '<table>';
     foreach($v as $n) echo "<tr><td>".join('</td><td>',$n)."</td></tr>";
             echo '</table>';  
    }
      

  3.   

    这个用法出现这个问题:Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38
    这是怎么回事?
      

  4.   

    数组是数据库中直接查询的结果 mysql_fetch_array()得到的
      

  5.   

    $info=@mysql_fetch_array($result,MYSQL_ASSOC);
    有了第二个参数也是不行的
      

  6.   

    <?php
    $match1=$_GET['match1'];
    $sex=$_GET['sex'];
    include("selectbyclass_in_match.php");
    include("conn.php");$result=mysql_query("select a.stu_id,a.user,a.sex,a.class,b.spo_name,a.is_houbu,a.mat_id from tb_match_mulper as a,tb_sport as b where a.spo_id='$match1' and a.sex='$sex' and a.spo_id=b.spo_id order by class,is_houbu");$info=@mysql_fetch_array($result,MYSQL_ASSOC);
    print_r($info);
    ?>
    <center>
    <?php
    foreach($info as $v)  $t[$v['group']][]=$v;
    foreach($t as $v){
             echo '<table>';
             foreach($v as $n) echo "<tr><td>".join('</td><td>',$n)."</td></tr>";
             echo '</table>';         
    }
    mysql_free_result($result);
    mysql_close($connID);
    ?>
      

  7.   

    $info=mysql_fetch_array($result,MYSQL_ASSOC);
    print_r($info);   去掉@ ,贴出结果 
      

  8.   

    结果没变,还是一大串的Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38Warning: join() [function.join]: Invalid arguments passed in F:\Website\www\project\teacher\text_2.php on line 38
      

  9.   

    print_r($info);   //贴这个结果
      

  10.   

    试试这个,自己写的,分离出来挺麻烦的,你在分析分析
     <td align="center" valign="top">
    <?php
    include("conn/conn.php");
    if(!filter_var($_POST[materialid], FILTER_VALIDATE_INT))
    {
    $Row[MaterialID]="您输入的不是编号!";
    $Row[MaterialNameEN]="您输入的不是编号!";
      $Row[MaterialNameCN]="您输入的不是编号!";
        $Row[Description]="您输入的不是编号!";
    }
    else
    { $query=mssql_query("select ParameterName,ParameterValue,ParameterUnit,Description from MaterialParaBro where MaterialID='".$_POST[materialid]."'");
    $result=mssql_fetch_array($query);
            if($result==false){
    ?> 
              <table width="100%" height="30"  border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="36" align="center" id="tabletext">暂无参数信息!</td>
                </tr>
              </table>
              <table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
      </tr>
    </table>
     <?php
    }else{
    ?>
     <table width="100%" height="33px" border="0" cellspacing="0" cellpadding="0" >
      <tr>
      </tr>
    </table>  
      <table width="100%" height="33px" cellpadding="0" cellspacing="1" border="1px solid #0c406d">
      <tr align="center" bgcolor="#1c65a6" border="1px solid #0c406d">
        <td width="30%" id="table">参数名称</td>  
        <td width="15%" id="table">参数值</td>
        <td width="10%" id="table">参数单位</td>
        <td width="45%" id="table">参数描述</td>
      </tr>
    <?php do{ ?>
      <tr bgcolor="#cbcbcb" >
        <td style="padding:5px; border-right-color:1px solid #0c406d" id="tabletext">&nbsp;<?php echo $result[ParameterName];?></td>  
        <td style="padding:5px;" id="tabletext">&nbsp;<?php echo $result[ParameterValue];?></td>
        <td style="padding:5px;" id="tabletext">&nbsp;<?php echo $result[ParameterUnit];?></td>  
        <td style="padding:5px;" id="tabletextde">&nbsp;<?php echo $result[Description];?></td>  
      </tr>
    <?
      }while($result=mssql_fetch_array($query));
    }}
    ?>  
    </table></td>
          </tr>
        </table>
    </td>
      </tr>
      </tr>
    <tr>&nbsp;&nbsp;</tr>
    </table>
    </td>