4

私は助けが必要です。ユーザーが 3 つのドロップダウンから選択する 3 つのデータ値を表示したいと考えています。ユーザーがデータベースからそれぞれに 3 つの異なるオプションを選択する 3 つのドロップダウン リストを作成しました。ユーザーが選択するものはすべてテーブルに表示される必要があります。たとえば、ユーザーが selection_id に 111 を選択し、fixture_id に 222 を選択した場合、名前に Jesty を選択すると 、表では111 222 Jestyと表示されます。今のところ、データベースから情報を取得してドロップダウンを表示するドロップダウンしかありません....ユーザーの選択を表示する方法、またはユーザーが選択したものをユーザーに出力するjavascriptが必要です

これが私の3つのドロップダウンリストです

require "config.php"; //Database connection
    $resource_selections = mysql_query("SELECT DISTINCT selection_id FROM selections ORDER BY selection_id ASC");
    $selections = array();
    while($row = mysql_fetch_row($resource_selections)){
        $selections[] = $row[0];    
    } 
    $resource_fixtures = mysql_query("SELECT DISTINCT fixture_id FROM selections ORDER BY selection_id ASC"); 
    $fixtures = array();
    while($row = mysql_fetch_row($resource_fixtures)){
        $fixtures[] = $row[0];
    } 
    $resource_names   = mysql_query("SELECT DISTINCT name FROM selections ORDER BY selection_id ASC");    
    $names = array();
    while($row = mysql_fetch_row($resource_names)){
        $names[] = $row[0];
    }
    if(count($selections) <= 0 || count($fixtures) <= 0 || count($names) <= 0){
        echo 'No results have been found.';
    } else {

        // Display form
        echo '<form name="form" method="post" action="selection.php">';

        //SelectionID dropdown:
        echo "<select name='selection_id' id='selections' >"; 
        foreach($selections as $selection) echo "<option id='$selection'>$selection</option>";
        echo '</select>';

        //FixtureID dropdown
        echo "<select name='fixture_id' id='fixtures' >"; 
        foreach($fixtures as $fixture) echo "<option id='$fixture'>$fixture</option>";
        echo '</select>';

        //Name dropdown
        echo "<select name='name' id='names' >"; 
        foreach($names as $name) echo "<option id='$name'>$name</option>";
        echo '</select>';

        echo "<input type='submit' name='submit' value='Submit' />";




        echo '</form>';



    }


    ?>
4

2 に答える 2