2012-02-28 6 views
0

誰かが私を助けてくれるかどうか疑問に思う。ラジオボタンをクリックしてテーブルを作成する

ログオンしているユーザーに関連する日付と関連するラジオボタンのリストを作成する以下のコードをまとめました。私はとの難しさを抱えているこれ、行うことができるようにしたいのですがどのような

<?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」該当のリストを画面に描画するために、別のテーブルを希望選択されるとあります選択した日付まで

私は最初の部分を動作させることができましたが、ラジオボタンが選択されても何も起こりません。

私はこれにかなりの時間を費やしましたが、答えを見つけることができないようです。

私はちょうど誰かがこれを見て、私が間違っている場所を教えてくれたかどうか疑問に思った。

感謝

あなたはjQueryのまたはJavaScriptを必要とし、これを行うために修正コード

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

ajax() –

答えて

0

.load() is the easiest to doこれは、ページから既にページに存在するdivにページまたはdivをロードします。これは.Click()または.change()とすることができます。

+0

こんにちは、これは多くのありがとうございます。私はJavascriptで特に経験されていないことを認めなければならないが、私はあなたが示唆していると思っていることをまとめている。私は確信していない唯一のものは、複数の場合は、正しいfindnameまたは名前を結びつける方法です。コードの変更を反映するために私は元の投稿を修正しました。おそらくこれを見て、ボタンと正しい詳細をリンクする方法についてのガイダンスを提供することができますか?どうもありがとう – IRHM

関連する問題