Строка value="<?= $otwet['answers'] ?> постоянно выводит только 1 ответ из базы, а нужно все ответы для даного вопроса. Свою базу данных добавил...
<? require_once '../config/mysql.php'; ?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="get" action="/admin/add.php">
<?
if (!empty($_GET['voprosu'])) {
$vopros_id = $_GET['voprosu'];
} else {
$vopros_id = 1;
}
$result = mysql_query("SELECT * FROM voprosu WHERE id = '$vopros_id'") or die(mysql_error());
$result1 = mysql_query("SELECT * FROM otvetu WHERE id_voprosa='$vopros_id'") or die(mysql_error());
while ($data1 = mysql_fetch_assoc($result1)) {
$otveti[$data1['id_voprosa']][] = $data1;
while ($data = mysql_fetch_assoc($result)) {
foreach ($otveti[$data['id']] as $otwet) {
?>
<p>Номер вашего вопроса <input type="number" name="number" value="<?= $vopros_id ?>" onChange="javascript:window.location.href = 'http://question.local/admin/index.php?voprosu=' + this.value;"/></p>
<p> <input type="text" name="page" size="100" value="<?= $data['voprosu']; ?>"/></p>
<p>Добавьте варианты ответов на вопрос </p>
<input type="text" name="answers1" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio1"/>
<br>
<input type="text" name="answers2" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio2"/>
<br>
<input type="text" name="answers3" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio3"/>
<br>
<input type="text" name="answers4" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio4"/>
<br>
<input type="text" name="answers5" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio5"/>
<br>
<input type="text" name="answers6" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio6"/>
<br>
<input type="text" name="answers7" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio7"/>
<br>
<input type="text" name="answers8" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio8"/>
<br>
<input type="text" name="answers9" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio9"/>
<br>
<input type="text" name="answers10" value="<?= $otwet['answers'] ?> "/> <input type="radio" name="radio10"/>
<? } ?>
<? } ?>
<? } ?>
<p><input type="submit" /></p>
</form>
</body>
</html>