php veri manipülasyon html

2 Cevap

Given this code snippet, I know that if the user selects 25c the value 25 will be sent to the php script; however, I am having issues trying to figure out how to setup the data on the php script so that I could manipulate it.

   <label><b>Quarters:</b></label>
    <select name="quarters" >
    <option value="25">25c</option>
    <option value="50">50c</option>
    <option value="75">75c</option>
    <option value="100">$1.00</option>
    </select>

Şu anda tüm php script üzerinde şudur:

// A money array.
    $money = array("Nickels" => "$value", "Dimes" => "$value", "Quarters" =>"$value");

If the user clicks on the option for for Quarters and selects 50c the value will be 50 on the HTML side, but how do I get that 50 onto the php side, since this value is depended on what the user selects, in some cases the user can select 75c, and the value 75 is transferred to the php script.

Sadece tek bir değeri tutan bir değişken kullanamazsınız, bu yüzden bir kullanıcı $ 1,00 değer 100 25c değeri 25 seçebileceğiniz tüm olası değerleri tutmak için çok boyutlu bir dizi düşünüyorum.

Kullanıcı tek bir seferde değeri olmayan değerlerin bir kombinasyonunu seçebilirsiniz.

2 Cevap

Yapabileceğin bir şey, yerine $_REQUEST dizi kullanın, $value sizin Nickels, Dimes, and Quarters girişler için kullanan biridir.

Örneğin, örnek, dizi olurdu:

// A money array.
    $money = array("Nickels" => $_REQUEST["nickels"], "Dimes" => $_REQUEST["dimes"], "Quarters" =>$_REQUEST["quarters"]);

Nickels / Dimes için adlandırma kuralı sizin Çeyrek örnek ile tutarlı olduğunu varsayarak.