Background: We are launching a event which would be attended by students from various Universities. A web application would report live as to number of students registering for the event.
The basic web layout is
I hope the desired layout is clear. This needs to refresh every 5 mins to display as new students are registered. I have got the refresh part done using Ajax setTimeout() method.
I have table Student
. The query I am using is:
SELECT UNIV, STUDENT_NAME, STUDENT_EMAIL
FROM STUDENT
ORDER BY UNIV;
However, the main issue is identifying when to add new row in the table and displaying the details
Issue 1: Currently, what I am doing is having $currUniv
variable which refers to the current value of University. If the value of $currUniv
and current row fetched don't match, I create a new row
Code: in updater.php
function updateTable()
{
$currUniv = "";
while($currLine = mysql_fetch_array($results))
{
if (strcmp($currLine[0], $currUniv) != 0)
{
responseHTML .= "<tr id = \"{$currLine[0]}\">";
responseHTML .= "<td id = \"{$GLOBALS["univ"]}\">";
responseHTML .= "{$currLine[0]}";
responseHTML .= "</td>";
$currUniv = $currLine[0];
}
responseHTML .= "<td id = \"{$GLOBALS["studentname"]}\">";
responseHTML .= "{$currLine[1]}";
responseHTML .= "</td>";
responseHTML .= "<td id = \"{$GLOBALS["studentemail"]}\">";
responseHTML /= "{$currLine[2]}";
responseHTML .= "</td>";
if (strcmp($currLine[0], $currUniv) != 0)
{
responseHTML .= "</tr>";
}
}
}
Firstly, the table is not displayed. I don't think this is the best algorithm to create the table. Can anyone suggest me any other means of achieving the same?