2014-05-09 10:22
浏览 15


I have store my student database in a table student. When the session is over I move the database to different table alumni. And I have form for querying those students where I put session/Year selection. For current session I have no problem querying the database. But for querying previous years student database from alumni in the same form I have no idea how I would query. I just used the following code but this code is limited to one previous year and do not cover the whole past years. Please help me as I am new to this.


 $pyr=date("Y")-1;//Current Year minus one equals to Previous year.
 $query_pic = "SELECT * FROM alumni WHERE regd='$regd' and Year='$yr'";
  $query_pic = "SELECT * FROM student WHERE regd='$regd' and Year='$yr'";

Now I want to dynamically select all the past years student database which were stored in alumni table.

图片转代码服务由CSDN问答提供 功能建议

我将学生数据库存储在表 student </ code>中。 会话结束后,我将数据库移动到不同的表 alumni </ code>。 我有一个表格,用于查询那些我选择会话/年份的学生。 对于当前会话,我查询数据库没有问题。 但是为了从同一形式的校友查询前几年的学生数据库,我不知道我将如何查询。 我刚刚使用了以下代码,但此代码仅限于前一年,并未覆盖整个过去几年。 请帮助我,因为我是新手。</ p>

  $ regd = $ _ GET ['regd']; 
 $ yr = $ _ GET ['Year']; 
 $ pyr = date(“Y”) -  1; //当前年份减1等于上一年。
 if($ yr == $ pyr){
 $ query_pic =“SELECT * FROM alumni WHERE regd =  '$ regd'和Year ='$ yr'“; 
} else {
 $ query_pic =”SELECT * FROM student WHERE regd ='$ regd'and Year ='$ yr'“; 
 <  / code> </ pre> 

现在我想动态选择存储在 alumni </ code>表中的所有过去几年的学生数据库。</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题