I have a dropdown box to choose topics from a discussiob board so i can then view all the replies for deletion etc.
At the minute when I choose a topic i then press a submit button and get all the answers. But is there any wayt i could have it so that the answers just get displayeds depending what is shown in the dropdown box?
This is my code to populate the dro[pdown.
<?php
'../inc/connect.php';
//populate form dropdown box
$op = '';
$r = "SELECT id, topic FROM forum_question ORDER BY id";
$result = $link->query($r);
if (mysqli_num_rows($result)){
$comment = 0;
if(isset($_POST['comment'])) $comment = (int) $_POST['comment'];
while ($d = mysqli_fetch_assoc($result)){
$sel = ($comment == $d['id']) ? " selected='selected' " : '';
$op .= "\n\t<option value='{$d['id']}'$sel>{$d['topic']}</option>";
}
}
?>
And this is my form that contains the dropdown and shows the answers
<form class='form2' action='forumadminpage.php' method='post' enctype='multipart/form-data'>
<b><span class='formheading'>Choose A Topic</span><br />To Remove Comments</b><br />
<select name="comments">
<?php echo $op;?>
</select>
<input type='submit' name='submit' value='Get Comments' />
<?php
include '../inc/connect.php';
if(isset($_POST['submit'])){
$comments= intval($_POST['comments']);
$data = mysqli_query($link, "SELECT * FROM forum_answer WHERE question_id IN ($comments) ")
or die(mysql_error());
while($info = mysqli_fetch_array( $data )) {
echo "<p>";
echo "<input type='checkbox' name='remove[{$info['id']}]' value='Remove' />";
echo $info['id'];
echo ': ';
echo $info['a_title'];
echo "</p>";
}
echo"<input type='submit' name='submit' value='Delete Comments' />";
}
?>
</form>
Thanks for looking........