Интересно, может ли кто-нибудь помочь мне.Создать таблицу на кнопке радио Нажмите
Я собрал приведенный ниже код, который создает список дат и связанных с ними переключателей, относящихся к пользователю, который вошел в систему.
<?php
mysql_connect("hostname", "username", "password")or
die(mysql_error());
mysql_select_db("database");
$result = mysql_query("SELECT userdetails.userid, finds.dateoftrip, detectinglocations.locationname, finds.userid, finds.locationid, detectinglocations.locationid, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 GROUP By dateoftrip ORDER BY dateoftrip DESC");
if (mysql_num_rows($result) == 0)
// table is empty
echo 'There are currently no finds recorded for this location.';
else
{
echo"<table>\n";
while (list($userid, $dateoftrip, $findname) =
mysql_fetch_row($result))
{
echo"<tr>\n"
.
"<td><input type='radio' name='show' dateoftrip value='{$dateoftrip}' /></td>\n"
."<td><small>{$dateoftrip}</small><td>\n"
."</tr>\n";
}
echo'</table>';
}
?>
<form action="<?=$PHP_SELF?>" method="POST" enctype="multipart/form-data" class="style10">
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['show']))
$dateoftrip = intval($_POST['show']);
echo"<table>\n";
while (list($dateoftrip, $findname) =
mysql_fetch_row($result))
{
echo"<tr>\n"
."<td><small>{$findname}</small><td>\n"
."</tr>\n";
}
echo'</table>';
}
?>
<input type="hidden" name="action" id="action" />
</form>
То, что я хотел бы быть в состоянии сделать, что я с трудом с, это на кнопку радио выбран Я хотел бы еще одну таблицу для отображения на экране со списком «findnames» применимо на выбранную дату.
Мне удалось получить первую часть работы, но при выборе переключателя ничего не происходит.
Я потратил немало времени на это, но я просто не могу найти ответ.
Я просто задавался вопросом, может ли кто-нибудь, возможно, взглянуть на это, пожалуйста, и дайте мне знать, где я ошибся.
Большое спасибо
Измененный Кодекс
<?php
mysql_connect("hostname", "username", "passowrd")or
die(mysql_error());
mysql_select_db("database");
$result = mysql_query("SELECT userdetails.userid, finds.dateoftrip, detectinglocations.locationname, finds.userid, finds.locationid, detectinglocations.locationid, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 GROUP By dateoftrip ORDER BY dateoftrip DESC");
if (mysql_num_rows($result) == 0)
// table is empty
echo 'There are currently no finds recorded for this location.';
else
{
echo"<table>\n";
while (list($userid, $dateoftrip, $findname) =
mysql_fetch_row($result))
{
echo"<tr>\n"
.
"<td><input type='radio' name='show' onclick dateoftrip value='{$dateoftrip}' /></td>\n"
."<td><small>{$dateoftrip}</small><td>\n"
."</tr>\n";
}
echo'</table>';
}
?>
<table width="300" border="1">
<tr id="findname"><th>Findname</th></tr>
</table>
<script type="text/javascript">
function displayRow(){
var row = document.getElementById("findname");
if (row.style.display == '')
row.style.display = 'none'; else row.style.display = '';
}
</script>
сделать это с ajax() –