J
|
Jane 7/4/2006 |
Terry, global $conn; //number of active student //tablename is your actual table name //field is you actual field $sql = "select count() from tablename where field='active'"; $rs=db_query($sql,$conn); $data=db_fetch_numarray($rs); $count=$data[0]; //number of students, which aren't active or awaiting tutor $sql1 = "select count() from tablename where field<>'active' and field<>'awaiting tutor'"; $rs1=db_query($sql1,$conn); $data1=db_fetch_numarray($rs1); $count-=$data1[0]; //save results in the anothertable //another table - is your actual table name $sql2 = "update anothertable set countfield=".$count; db_exec($sql2,$conn);
|
T
|
TerryB author 7/4/2006 |
Thanks Jane, |
T
|
TerryB author 7/4/2006 |
OK, I am getting an error but I realise there is a problem with how I described this. |
![]() |
Alexey admin 7/4/2006 |
Terry, select ... (select count(*) from students where tutorid=Tutors.id) as studentcount from Tutors
select ... (select count( case when status='active' then 1 when status<>'active' and status<>'awaiting tutor' then -1 end ) from students where tutorid=Tutors.id) as studentcount from Tutors
|