i guess that will work too but i decided to start a new simpler one
int this one i choose a conference (the list of choices include only the conferences the user is organizing) and his choice outputs a table that shows all the authors and the reviewers for this conference.
this list of authors and reviewers have checkboxes beside them and i have to select from them which ones i want to send a message to .... basically i got most of it covered but im having problems actually sending the message to these people
i copy pasted my code but if its hard to view just let me know if i can send it to someone's email to view it properly and help me out
i have 2 php file ... first one is where the users chooses a conference and the second is where the user chooses who recieves the message and another one that include the sending part
and again sorry for all the code i pasted
chooseconference.php
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('mydb');
$sql = "SELECT conference_id, short_name FROM conference";
$result = mysql_query($sql);
$num_rows=mysql_num_rows($result);
mysql_close($con);
?>
<form name="chooseconference" action="choosepeople.php" method="POST">
Conference: <select name="conference">
<?php
for($i=0;$i<$num_rows;$i++)
{
$conference_id=mysql_result($result,$i,0);
$short_name=mysql_result($result,$i,1);
echo '<option value="'.$conference_id.'">'.$short_name.'</option>';
}
?>
</select>
</br>
<input type="submit" value="submit" name="submit" />
</form>
choosepeople.php
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('mydb');
//$confID = $_POST["conference"];
$confID = 1;
$query = "SELECT M.first_name, M.last_name, M.member_id
FROM Member M INNER JOIN member_privileges MP
ON M.member_id = MP.member_id
INNER JOIN privileges Pr
ON MP.privileges_id = Pr.privileges_id
WHERE MP.conference_id = $confID
AND Pr.role = 'author'";
echo '<form name="post" method="POST" action="viewmessages.php">';
$authors = mysql_query($query) or die(mysql_error());
if (!$query) {echo "query error";}
if ($authors)
{
print "<table width=500 border=1>\n";
print "<tr>\n";
print "<th> </th>\n";
print "<th><width=\"0%\" height=\"0\" style=\"display:none\" value=\"Member ID\"</th>\n";
print "<th> Author Name </th>\n";
print "</tr>\n";
//create table
$i = 0;
while ( $row = mysql_fetch_array($authors) ) {
$i++;
print "<tr>\n";
print "<td><input type=\"checkbox\" name=\"authors[]\" value=\"$row[member_id]\"></td>\n";
echo "<td><width=\"0%\" height=\"0\" style=\"display:none\" value=\"{$row['member_id']}\"</td>\n";
echo "<td>{$row['first_name']} {$row['last_name']}</td>\n";
echo "</tr>\n";
}//end while
print "</table>\n";
$reviewers = mysql_query("SELECT M.first_name, M.last_name, M.member_id
FROM Member M
INNER JOIN member_privileges MP
ON M.member_id = MP.member_id
INNER JOIN privileges Pr
ON MP.privileges_id = Pr.privileges_id
WHERE MP.conference_id = $confID
AND Pr.role = 'reviewer'") or die(mysql_error());
if ($reviewers)
{
print "<table width=500 border=1>\n";
print "<tr>\n";
print "<th> </th>\n";
print "<th><width=\"0%\" height=\"0\" style=\"display:none\" value=\"Member ID\"</th>\n";
print "<th> Reviewer Name </th>\n";
print "</tr>\n";
//create table
$i = 0;
while ( $row = mysql_fetch_array($reviewers) ) {
$i++;
print "<tr>\n";
print "<td><input type=\"checkbox\" name=\"reviewers[]\" value=\"$row[member_id]\"></td>\n";
echo "<td><width=\"0%\" height=\"0\" style=\"display:none\" value=\"{$row['member_id']}\"</td>\n";
echo "<td>{$row['first_name']} {$row['last_name']}</td>\n";
echo "</tr>\n";
}//end while
print "</table>\n";
}
}
mysql_close($con);
?>
<div>
<textarea name="body" rows="20" cols="110"><?php // if(isset($_POST['body']))echo htmlentities($_POST['body']); ?></textarea>
</div>
<div>
<input type="submit" value="Send" name="Send"/>
</div>
</form>
viewmessages.php (idk why named it that)
<?php
$con=mysql_connect('localhost','root','');
if (!$con) {
die ("con error");
}
else
{
$message=$_POST['body'];
$x = $_POST['authors'];
//$fulexp = implode(",", $x);
//echo $fulexp;
//$n = count($x);
if( isset($x) && is_array($x))
{
$fulexp = implode(",", $x);
foreach ($x as $item)
{
$fulexp = implode(",", $x);
$var = intval($item);
mysql_select_db('mydb');
$re = mysql_query("INSERT INTO member_message_member (member_id1, member_id2,conference_id, message)
VALUES (6, $var, 1, $message)");
////the value 6 and 1 are defualt here no need to change now
if (!$re) {echo "error";}
}
}
else {echo "didnot enter foreach";}
mysql_close($con);
}
?>