It's year-end survey time! Do you have a theatrical resolution for 2014?";
$key = 'resolution';
$sql = "select count(a) from {survey} where q='%s' and uid=%d";
$count = db_result(db_query($sql, $key, $user->uid));
if (isset($_POST['submit'])) {
$sql = "insert into {survey} (uid, q, a) values (%d, '%s', '%s')";
db_query($sql, $user->uid, $key, $_POST['a']);
print 'Thanks for taking our survey. Your answer has been included in the results below.';
} else {
if ($user->uid) {
if ($count == 0) {
?>
You have already answered this survey. Check out the results so far below.';
}
} else {
print '
Login so you can add your answer to this survey. Check out the results so far below.';
}
}
print '';
$sql = "select a as word, count(uid) as qty from {survey} where q='%s' group by word";
$result = db_query($sql, $key);
while($data = db_fetch_object($result)) {
$pie_values .= ", ['" . $data->word . "', " . $data->qty . "]";
}
print '
";
print '
';
?>