我想知道是否有人能夠幫助我。在單選按鈕上創建表格單擊
我把下面的代碼放在一起,它創建了與登錄用戶相關的日期和相關單選按鈕列表。
<?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() – 2012-02-28 13:38:57