0

これが簡単であることはわかっていますが、その方法を教えてくれるリソースが見つかりません。

私のコードは次のとおりです。

session_start();
$wquery=
"select week_num,week_name
from stats_week
where season=$this_season
order by week_num";
    $wresult=mysql_query($wquery);


print'<form action="changeplayer_2.php" method="post">';


        print"<select name='Week_select'> <br>";
        while ($wrow=mysql_fetch_array($wresult))
    { 
    print '<option value="'.$wrow['week_num'].'">'.'week '.$wrow['week_num'].'     '.$wrow['week_name'].'</option><br>\n';  
    }

print "</select><br><br>";#

    print'<button type="submit" >Next</button>';


    print"</form>";

だから私は選択をしています: 私はその選択を最終的にしたい: $_SESSION['week']

4

3 に答える 3

1

you can do this either sending data by form on submit or if you want to do without refreshing page you can do this by ajax

and than set like this

$_SESSION['week']=isset($_POST['Week_select'])?$_POST['Week_select']:someDefau‌​lt;

and to do this by ajax check this answer

于 2013-04-12T04:43:48.717 に答える
0

Inside file "changeplayer_2.php" you'll want to load the POSTed value to the session:

session_start();
$_SESSION['week'] = $_POST['Week_select'];

Whenever you want to get the value of the session at key 'week', simply do:

$weekValue = isset($_SESSION['week']) ? $_SESSION['week'] : false;

But if you do use the session variable on any script, make sure you start the session using session_start().

To destroy the session variable, you can do:

session_start();
unset($_SESSION['week']);
于 2013-04-12T04:44:23.417 に答える