hello all,
im having trouble making a certain variable update.
ive tried different ways such as ++$new_result, $new_result = ($result3[result] + 1); and $new_result = ($result3[result] ++);
here's the line where the incrementing is supposed to take place
$new_result = ($result3[result] + 1);
here's the whole file:
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catLeft" colspan="3" height="28"><span class="cattitle">Participate</span></td>
</tr>
<tr>
<td class="row1" align="left" width="100%">
<span class="gensmall">
<?php
include ("includes/auth_check.php");
$user_id = $_SESSION['user_id'];
//check to see if survey_id was given
if (isset($_GET['survey_id'])){
//get option_ids for query
$sql0 = mysql_query("SELECT * FROM `survey_choices` WHERE `survey_id` = '$_GET[survey_id]'");
$result2 = $sql0;
$result3 = mysql_fetch_array($sql0);
//check if the user has participated already
$sql3 = mysql_query("SELECT * FROM `survey_activity` WHERE `survey_id` = '$_GET[survey_id]' AND `user_id` = '$user_id'");
$result1 = mysql_num_rows($sql3);
if ($result1 > 0){
?>
You have already participated.<br />
<?php
}
else
{
if (!isset($_POST['option_id'])){
?>
You did not select anything. Go back and select something if you want to participate.
<?php
exit;
}
//first, we need to get the current result of the poll choice and add one to it so that we can update survey_choices
$new_result = ($result3[result] + 1);
$sql1 = ("UPDATE `survey_choices` SET `result` = '$new_result' WHERE `survey_id` = '$_GET[survey_id]' AND `option_id` = '$_POST[option_id]'");
echo $sql1;
//next, we need to add the user's activity to the survey_activity table
$date = (date("Y-m-d G:i:s"));
$survey_id = ($_GET['survey_id']);
$user_ip = ($_SERVER['REMOTE_ADDR']);
$sql2 = ("INSERT INTO `survey_activity` (`survey_id`, `user_id`, `survey_option`, `user_choice`, `user_ip`, `time`) VALUES ('$survey_id', '$user_id', '$_POST[option_id]', '$_POST[option_id]', '$user_ip', '$date')");
//execute queries
/*mysql_query ($sql1);
mysql_query ($sql2);*/
}
?>
Thank you for participating.<br />
<br />
<a href = "index.php?action=list">Click here</a> to go back to the list<br />
<?php
}
?>
</span>
</td>
</tr>
</table>
hopefully someone can help me out 😕