在单选按钮上创建表单击

时间:2012-02-28 13:17:04

标签: php html

我想知道是否有人可以帮助我。

我将下面的代码放在一起,创建了一个日期列表以及与登录用户相关的相关单选按钮。

<?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>

1 个答案:

答案 0 :(得分:0)

要做到这一点,你需要JQuery或javascript。 .load() is the easiest to do它会将页面或div从页面加载到已存在于页面上的div中。您可以执行此操作.Click().change()