现在做一个学生系统,打算用学生基本信息表中的两个字段来决定一条学生记录。
比如,学生表中的字段:(学号)id   (姓名)name  (年龄)age   (录入时间)time
现在想要将id和time字段合起来去决定一条学生记录,不知道用concat()函数怎么实现?系统的大致流程:首先,在学生表中增加学生记录;然后,在三好学生表中为个别学生增加三好学生的称号,在增加三号学生称号的时候通过 id + time 共同确定一条学生记录,最后选定这条学生记录,增加三好生称号。晒晒我的代码:
<?php
  $sql="select concat(id,time) as id from student";
  $rs=mysql_query($sql);
  $rw=mysql_fetch_array($rs);
?> ...<td>
<a href="sanhaosheng_add.php?id=<?php echo $rw[0];?>">选定</a>
</td>我用的开发工具是wamp 5.0  
系统报错为:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...请大家帮帮忙!谢谢了先!

解决方案 »

  1.   

    $sql="select concat(id,time) as id from student";//你的数据库中有数据不?
    最好写成这样,方便你以后分割使用它。
    $sql="select concat(id,'-',time) as id from student";
      

  2.   

    回复1楼:
        现在能把两个字段连接上,但是在选定的时候,
    <td> 
    <a href="sanhaosheng_add.php?id= <?php echo $rw[0];?>">选定 </a> 
    </td> 
     为什么id=空 ?在状态栏中什么都不显示啊?
      

  3.   

    $rw=mysql_fetch_array($rs); 改为
    $rw=mysql_fetch_row($rs); 
      

  4.   


    $sql="select concat(id,time) as id from student";
      $rs=mysql_query($sql);
      $rw=mysql_fetch_row($rs);
      echo $rw[0];//这里是否有值?如果没有,那确定你数据库里面是否有值。