I have now incorporated a search function using PHP which lets the user search for questions by keyword. It searches my database for any questions with that keyword and displays them on the page. I can't figure out how to make the buttons work to display the answer similar to my HTML page.
Here is what I have so far:
- Code: Select all
while($row = mysql_fetch_array($result)){
$id = nl2br($row ['id']);
echo "<tr><td>Question: </span>". nl2br($row ['question']). "<br>";
echo "<input type='button' class='buttonQuestion' onClick='document.getElementById('q$id')style.display='block';' value='View Answer'>";
echo "<input type='button' class='buttonQuestion' onClick='document.getElementById('q$id')style.display='none';' value='Hide Answer'>";
echo "<div id='q$id' style='display:none;'>Answer: ".nl2br($row ['answer']). "</div";
}
Right now it displays the question and buttons... it hides the answer but my buttons don't work when you click on them. Any ideas???



