0

good day mates!

is there any alternative for this code? i need to get the user input so i can count the number of records to a condition.

$result = mysql_query("SELECT * FROM exam order by rand()") or die(mysql_error()); 
			echo "<center><font size=2 face=Arial><b>Awareness and Reminders</b></font></center><br/>";
			echo "<font size=1 face=Arial><b>Type in True if the statement is correct and False if otherwise.</b></font><br/><br/>";		
			echo "<table cellpadding = 1><tr><th><font size = 1>Answer</th><th><font size = 1>Question</th></tr>";
			
			while($row = mysql_fetch_array($result))
			{
				echo "<tr><td>";  
				echo "<font size = 1><input name='answer' type='text'>";		
         		echo "</font></td><td><font size = 1>";	
				$question = $row['question'];
				$answer = $row['answer'];
				$id = $row['questionid'];
				echo $question;
      			echo "</td></tr>"; 
			}
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by tomatocms
0
<input name='answer[]' type='text'>";

use above html code then you will get arrary of answer text box in php when form is submited

0
$answers = $_POST['answer'];
// Loop through it
for ($i = 0; $i < count($answers); $i++) {
  echo $answers[$i].'<br />';
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.