2

誰か助けてください。

ユーザーが自分のアカウントに保存されたレコードを表示できるように、このページをまとめました。

私が今やろうとしているのは、ユーザーがラジオ ボタンを選択して [場所の詳細] アイコンをクリックすると、ラジオを選択したレコードに関連する [詳細ページ] に移動できる機能を追加することです。反対のボタン。

私が抱えている問題は、どのラジオ ボタンを選択しても、アイコンをクリックすると、常に最後のレコードの「詳細ページ」に移動することです。(* NB * この投稿の目的のために、ボタンから「送信」アクションを取り除きました。)

以下のコードは、テーブルと「場所の詳細」アイコンを作成します

 <table id="theTable" width="835" class="sortable-onload-zebra no-arrow rowstyle-alt colstyle-alt paginate-20 max-pages-20 paginationcallback-callbackTest-calculateTotalRating paginationcallback-callbackTest-displayTextInfo sortcompletecallback-callbackTest-calculateTotalRating">
              <thead>
                <tr>
                  <th width="60" bgcolor="#ff8401">Select</th>
                  <th width="150" class="sortable-text" bgcolor="#ff8401">Location</th>
                  <th width="300" class="sortable-text" bgcolor="#ff8401">Address</th>
                  <th width="30" class="sortable-text" bgcolor="#ff8401">Finds</th>
                </tr>
              </thead>
              <tbody>
                <?php
                    mysql_data_seek($result, 0);
                    while ($row = mysql_fetch_array($result)) {
                        /* display row for each user */

                ?>
                <tr height="80px">
                  <td style="text-align: center"><input type="radio" id="lid" name="lid" value=<?php echo $row['locationid'];?> /></td>
                  <td style="text-align: left"><strong><?php echo $row['locationname'];?></strong></td>
                  <td style="text-align: center"><?php echo $row['returnedaddress'];?></td>
                  <td style="text-align: center"><strong><em><?php echo $row['totalfinds'];?></em></strong></td>

            </tr>

                <?php
                        }
                    } else {
                        echo "<tr>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>                                     
                            </tr>
                            <tr>
                                 <td colspan='5'><div align='center'><strong>No locations have been added yet. <a href='addlocation.php'>Click here</a> to add one.</strong></div></td>
                            </tr>
                            <tr>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                                 <td>&nbsp;</td>
                            </tr>";

}

?>  
              <form action='locationsaction.php'>
              <input type='submit' class='detailsButton' name='type' value='Details' alt='Location Details' title='Location Details' style='margin-right:10px' />
              </form>   
            </tbody>
            </table>

1 つのフォーム内に複数の送信ボタンを配置するつもりなので、上記のスクリプトで呼び出される次の「locationsaction.php」スクリプトを作成しました。

<?php
session_start();
$_SESSION['lid'] = $_POST['lid'];
if (isset($_POST['type'])) {
    $urls = array(
        'Details' => 'locationdetails.php',
        'Add Finds' => 'addfinds.php',
        'Images' => 'addimages.php',
        'View Finds' => 'locationfinds.php'
    );
    $url  = $urls[$_POST['type']];
    header("Location: " . $url);
}
?>

私はこれに数日間取り組んでおり、いくつかのチュートリアルを試しましたが、これを機能させることができないようです.

誰かがこれを見て、「送信アクション」で正しいラジオボタンの値を渡す方法についてのガイダンスを提供できるかどうか疑問に思いました.

多くの感謝と親切な敬意

4

2 に答える 2

2

これが現在のフォームです。

<form action='locationsaction.php'>
<input type='submit' class='detailsButton' name='type' value='Details' alt='Location Details' title='Location Details' style='margin-right:10px' />
</form> 

あなたのテーブルはまったくあなたの形ではありません。送信ボタンをクリックすると、<form>タグ間の入力の詳細のみが送信されます。

<form actionタグをページの一番上に移動すると、機能するはずです。

于 2012-09-19T13:55:14.657 に答える
2

フォームの開始タグは、最上部の入力タイプ フィールドの上にある必要があると思います。完全にはわかりませんが、それが最初に気づいたことです。

于 2012-09-19T13:55:31.443 に答える