Location: PHPKode > projects > Convener > manage/partanswers.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
	<title>Participant's answers</title>
	<style type="text/css" media="screen">@import "convener.css";</style>
</head>
<body>
<div id="wrapper">
	<div id="menu"><?php include('menu.php');?>
	</div>
	<div id="content"> 

<?php

require('../config.php');
require('../dbfunc.php');
$conveners_id = 1; // now for testing, set by authentication when it's ready

if ($_GET['p'] AND $_GET['m']) {
	$participants_id = escape_smart($_GET['p']);
	$meetings_id = escape_smart($_GET['m']);	
	// --- query participant's real name and meeting title
	$result = mysql_query("SELECT firstname, lastname FROM participants WHERE participants_id = $participants_id", $link);
	$name = mysql_fetch_row($result);
	$result = mysql_query("SELECT title FROM meetings WHERE meetings_id = $meetings_id", $link);
	$title = mysql_fetch_row($result);
	echo "<h2>$name[0] $name[1]'s answers for \"$title[0]\"</h2><table border=\"1\">";
	// --- query suggestions voted best by this user and save in array $best
	$result = mysql_query("SELECT MAX(answer) FROM answers WHERE participants_id = $participants_id AND meetings_id = $meetings_id");
	$high = mysql_fetch_row($result);
	$result = mysql_query("SELECT answer, suggestions_id FROM answers WHERE answer = '$high[0]' AND participants_id = '$participants_id' 
	AND meetings_id = '$meetings_id'");
	$best = array();
	while ($row = mysql_fetch_assoc($result)) {
		$best[] = $row['suggestions_id'];
	}
	
	if (suggformat($meetings_id)== 0) { // date+location suggestions
		echo '<tr class="tblh"><td>No.</td><td>Starting</td><td>Ending</td><td>Location</td><td>Answer</td><td>Comment</td></tr>';
		// --- query the suggestions for this meeting
		$result = mysql_query("SELECT * FROM suggestions WHERE meetings_id = $meetings_id ORDER BY suggestions_id ASC", $link);
		$i = 1; // to display suggestion number to users
	
		while ($row = mysql_fetch_assoc($result)) { // loop through every suggestion and display participant's answers
			// --- query the actual answers and comment messages
			$result_answer = mysql_query("SELECT answer, message FROM answers WHERE participants_id = $participants_id AND 
			meetings_id = $meetings_id AND suggestions_id = " . $row['suggestions_id'], $link);
			$answ = mysql_fetch_row($result_answer); 	
			echo '<tr' . (in_array($row['suggestions_id'], $best) ? ' class="greentr">' : '>') . "<td>$i</td><td>" . 
			$row['starttime'] . '</td><td>' . $row['endtime'] . '</td><td>' . $row['location'] . "</td><td>$answ[0]</td>
			<td>$answ[1]</td></tr>";
			$i++;
		}		
	} else { // freetext suggestions
		echo '<tr class="tblh"><td>No.</td><td>Suggestion</td><td>Answer</td><td>Comment</td></tr>';
		// --- query the suggestions for this meeting
		$result = mysql_query("SELECT suggestions_id, freetext FROM suggestions WHERE meetings_id = $meetings_id ORDER BY 
		suggestions_id ASC", $link);
		$i = 1; // to display suggestion number to users

		while ($row = mysql_fetch_assoc($result)) { // loop through every suggestion and display participant's answers
			// --- query the actual answers and comment messages
			$result_answer = mysql_query("SELECT answer, message FROM answers WHERE participants_id = $participants_id AND 
			meetings_id = $meetings_id AND suggestions_id = " . $row['suggestions_id'], $link);
			$answ = mysql_fetch_row($result_answer); 	
			echo '<tr' . (in_array($row['suggestions_id'], $best) ? ' class="greentr">' : '>') . "<td>$i</td><td>" . 
			$row['freetext'] . "</td><td>$answ[0]</td><td>$answ[1]</td></tr>";
			$i++;
		}		
	}
	echo '</table>';
} else {
	echo "<h2>Invalid link</h2>";
}
?>

</div>
</body>
</html>

Return current item: Convener