Code: Select all
<? php
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query='SELECT * FROM `events`';
$result=mysql_query($query);
$num=mysql_numrows($result);
$yes = "Yes";
$no = "No";
$maybe = "Maybe";
$blank = "";
$i = 0;
$j = 0;
$a = strcmp($attend,$yes);
$b = strcmp($attend,$no);
$c = strcmp($attend,$maybe);
echo "Submitting RSVP...<br>";
$counting = 0;
while ($counting < $num) {
if (strcmp($event, mysql_result($result,$counting,"eventid"))) {
if ($a == 0) {
$newCount = $counting - 1;
$ayes = mysql_result($result,$newCount,"yes");
$ayes .= " ".$_SESSION['user'];
$newResult = mysql_query('UPDATE `onezerv2_c3m`.`events` SET yes = \''.$ayes.'\' WHERE eventid = \''.$event.'\' ');
$freshmaybe = explode(" ", mysql_result($result,$newCount,"maybe"));
$k = count($freshmaybe);
while ($i < $k) {
echo '<br>i = '.$i;
$newMaybe = "";
$theUser = "".$_SESSION['user'];
$comp2 = strcmp($freshmaybe[$i], $theUser);
echo "<br>comp ".$comp2;
if($comp2 == 0) {
echo '<br>i = '.$i;
$change = $i;
echo '<br>original = "'.$freshmaybe[$change];
$freshmaybe[$i] = "";
echo '"<br>fresh = "'.$freshmaybe[$i];
echo '"<br>changed = "'.$freshmaybe[$change];
$space = " ";
echo '"<br>already rsvp\'d';
while ($j < $k) {
echo "<br>while loop i = ".$j;
echo '" and change = "'.$change;
if ((strcmp($freshmaybe[$j], $blank) != 0) && ($j != $change)) {
$newMaybe .= $freshmaybe[$j];
if ($j < $change - 1) {
$newMaybe .= $space;
}
echo "'<br>newMaybe = '".$newMaybe;
echo "'<br>";
}
else {
$newMaybe .= $freshmaybe[$j];
echo "<br>newMaybe = '".$newMaybe;
echo "'<br>";
}
$j++;
}
}
$i++;
}
if (($i == $k) && ($i != 0)) {
echo "<br>writing";
$newResult = mysql_query('UPDATE `onezerv2_c3m`.`events` SET maybe = \''.$newMaybe.'\' WHERE eventid = \''.$event.'\' ');
die();
}
die ();
}
}
$counting++;
}
?>