Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 37fa123

Browse files
committed
Deleted problems do not show any more zombie entries!
Closes #4
1 parent cb54f79 commit 37fa123

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

admin/profile.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@
4949
while($row = mysql_fetch_array($result)) {
5050
$sql = "SELECT name FROM problems WHERE sl=".$row['problem_id'];
5151
$res = mysql_query($sql);
52-
$field = mysql_fetch_array($res);
53-
echo("<tr><td><a href=\"#\" onclick=\"$('#area').load('preview.php', {action: 'code', uname: '".$_GET['uname']."', id: '".$row['problem_id']."', name: '".$field['name']."'});\">".$field['name']."</a></td><td><span class=\"badge badge-info\">".$row['attempts']);
54-
if($row['status'] == 1)
55-
echo("</span></td><td><span class=\"label label-warning\">Attempted</span></td></tr>\n");
56-
else if($row['status'] == 2)
57-
echo("</span></td><td><span class=\"label label-success\">Solved</span></td></tr>\n");
52+
if(mysql_num_rows($res) != 0) {
53+
$field = mysql_fetch_array($res);
54+
echo("<tr><td><a href=\"#\" onclick=\"$('#area').load('preview.php', {action: 'code', uname: '".$_GET['uname']."', id: '".$row['problem_id']."', name: '".$field['name']."'});\">".$field['name']."</a></td><td><span class=\"badge badge-info\">".$row['attempts']);
55+
if($row['status'] == 1)
56+
echo("</span></td><td><span class=\"label label-warning\">Attempted</span></td></tr>\n");
57+
else if($row['status'] == 2)
58+
echo("</span></td><td><span class=\"label label-success\">Solved</span></td></tr>\n");
59+
}
5860
}
5961
?>
6062
</tbody>

submissions.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
while($row = mysql_fetch_array($result)) {
4141
$sql = "SELECT name FROM problems WHERE sl=".$row['problem_id'];
4242
$res = mysql_query($sql);
43-
$field = mysql_fetch_array($res);
44-
echo("<tr><td><a href=\"solve.php?id=".$row['problem_id']."\">".$field['name']."</a></td><td><span class=\"badge badge-info\">".$row['attempts']);
45-
if($row['status'] == 1)
46-
echo("</span></td><td><span class=\"label label-warning\">Attempted</span></td></tr>\n");
47-
else if($row['status'] == 2)
48-
echo("</span></td><td><span class=\"label label-success\">Solved</span></td></tr>\n");
43+
if(mysql_num_rows($res) != 0) {
44+
$field = mysql_fetch_array($res);
45+
echo("<tr><td><a href=\"solve.php?id=".$row['problem_id']."\">".$field['name']."</a></td><td><span class=\"badge badge-info\">".$row['attempts']);
46+
if($row['status'] == 1)
47+
echo("</span></td><td><span class=\"label label-warning\">Attempted</span></td></tr>\n");
48+
else if($row['status'] == 2)
49+
echo("</span></td><td><span class=\"label label-success\">Solved</span></td></tr>\n");
50+
}
4951
}
5052
?>
5153
</tbody>

0 commit comments

Comments
 (0)