1

Hello i have a while loop inside a select box that loops to 10, and allows you to select one of the outputted options and when you go to submit it will put this into a section to be used again later but i cannot get it to work, the idea is to select an item, and then select the quantity i have a price script working with the item part but i cannot get the quantity to carry over in a session (tested by echo'ing the session) heres the loop

echo '<select class="color" name="tickquant"><option></option>';
    $i = 1;
    while ($i <= 10) {
        echo "<option value=\"$i\">$i</option>";
        $i++;
    }
echo '</select>';

I am using this to get the session

$tickquant = $_POST['i'];
$_SESSION['tickquant'] = $tickquant;

If anyone can see the problem with this can you give me an indication of where i am going wrong, after the session is made it uses a header redirect to a page that calls it and echo's it, but it doesnt echo so i know it's not getting through

4

2 回答 2

1

使用,for循环

echo '<select class="color" name="tickquant"><option></option>';

     for($i=1; $i <=10; $i++){
        echo "<option value='$i'> $i </option>";
      }

echo '</select>';
于 2013-05-10T23:56:24.457 回答
0
$tickquant = $_POST['tickquant']; //this is the change
$_SESSION['tickquant'] = $tickquant;
于 2013-05-10T23:57:57.100 回答