MHaris
08-17-2007, 10:20 AM
<br/>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
Change the answer to
<select name="changeanswer_opinion">
<option>For</option>
<option>Against</option>
</select>
for the question
<select name="changeanswer_question">
<?php
$sql = mysql_query("SELECT * FROM questions");
while($row = mysql_fetch_array($sql)){
$changeanswer_questions = $row['question'];
?>
<option><?php echo $changeanswer_questions; ?></option>
<?php
}
?>
</select>
of the candidate
<select name="changeanswer_candidate">
<option><?php echo $selected_candidate; ?></option>
</select>
<input type="submit" name="change_opinion">
</form>
<?php
$change_opinion = $_POST['change_opinion'];
$changeanswer_opinion = $_POST['changeanswer_opinion'];
$changeanswer_question = $_POST['changeanswer_question'];
$changeanswer_candidate = $candidate_id;
if(isset($change_opinion)){
mysql_query("UPDATE answers SET answer='$changeanswer_opinion' WHERE question_id='$qID' AND candidate_id='$changeanswer_candidate'") or die(mysql_error());
}
?>
What I can't do is grab the id of the question selected as a option here so I can use it in the update query.
<option><?php echo $changeanswer_questions; ?></option>
Any ideas how would I grab the id of the question?
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
Change the answer to
<select name="changeanswer_opinion">
<option>For</option>
<option>Against</option>
</select>
for the question
<select name="changeanswer_question">
<?php
$sql = mysql_query("SELECT * FROM questions");
while($row = mysql_fetch_array($sql)){
$changeanswer_questions = $row['question'];
?>
<option><?php echo $changeanswer_questions; ?></option>
<?php
}
?>
</select>
of the candidate
<select name="changeanswer_candidate">
<option><?php echo $selected_candidate; ?></option>
</select>
<input type="submit" name="change_opinion">
</form>
<?php
$change_opinion = $_POST['change_opinion'];
$changeanswer_opinion = $_POST['changeanswer_opinion'];
$changeanswer_question = $_POST['changeanswer_question'];
$changeanswer_candidate = $candidate_id;
if(isset($change_opinion)){
mysql_query("UPDATE answers SET answer='$changeanswer_opinion' WHERE question_id='$qID' AND candidate_id='$changeanswer_candidate'") or die(mysql_error());
}
?>
What I can't do is grab the id of the question selected as a option here so I can use it in the update query.
<option><?php echo $changeanswer_questions; ?></option>
Any ideas how would I grab the id of the question?