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>"; 
			}

Recommended Answers

All 3 Replies

<input name='answer[]' type='text'>";

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

how can i get the value from the array?

$answers = $_POST['answer'];
// Loop through it
for ($i = 0; $i < count($answers); $i++) {
  echo $answers[$i].'<br />';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.