我希望将2个$_POST
数组值相互相乘,并将echo
与提交时的总和相乘。
在这种情况下,它应该是$_POST['vindue1']
和$_POST['quantity']
我试过了:
echo "<p><strong>Your price: </strong>" . $_POST['vindue1'] * $_POST['quantity']. " Kr. </p>";
CODE:
<form action="" method="POST">
<div class="dropdown-option">
<select id="select" name="vindue1">
<option value="" >VÆLG POLERINGSTYPE</option>
<option value="60" <?php if(isset($_POST['vindue1']) && $_POST['vindue1'] == '60'){ echo 'selected'; } else { echo ''; } ?>>INDVENDIG + UDVENDIG</option>
<option value="40" <?php if(isset($_POST['vindue1']) && $_POST['vindue1'] == '40'){ echo 'selected'; } else { echo ''; } ?>>UDVENDIG</option>
<option value="40" <?php if(isset($_POST['vindue1']) && $_POST['vindue1'] == '40'){ echo 'selected'; } else { echo ''; } ?>>INDVENDIG</option>
<option value="85" <?php if(isset($_POST['vindue1']) && $_POST['vindue1'] == '85'){ echo 'selected'; } else { echo ''; } ?>>FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
</div>
<div class="quantity-field">
<input type="number" name="quantity" min="0" max="100" placeholder="STK.">
</div>
<div class="dropdown-option">
<select id="select" name="vindue2">
<option value="" selected>VÆLG POLERINGSTYPE</option>
<option value="90" <?php if(isset($_POST['vindue2']) && $_POST['vindue2'] == '60'){ echo 'selected'; } else { echo ''; } ?>>INDVENDIG + UDVENDIG</option>
<option value="65" <?php if(isset($_POST['vindue2']) && $_POST['vindue2'] == '60'){ echo 'selected'; } else { echo ''; } ?>>UDVENDIG</option>
<option value="65" <?php if(isset($_POST['vindue2']) && $_POST['vindue2'] == '60'){ echo 'selected'; } else { echo ''; } ?>>INDVENDIG</option>
<option value="125" <?php if(isset($_POST['vindue2']) && $_POST['vindue2'] == '60'){ echo 'selected'; } else { echo ''; } ?>>FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
<div class="quantity-field">
<input type="number" name="quantity" min="0" max="100" placeholder="STK.">
</div>
<div class="row contact-form-pris">
<div class="large-6 small-12 columns">
<label for="first_name">Fornavn *</label>
<input class="" name="first_name" id="first_name" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="last_name">Efternavn *</label>
<input class="" name="last_name" id="last_name" type="text" required/>
</div>
<div class="large-12 columns">
<label for="address_street">Adresse *</label>
<input class="" name="address_street" id="address_street" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="email_address">Email *</label>
<input class="" name="email_address" id="email_address" type="email" required/>
</div>
<div class="large-6 small-12 columns">
<label for="mobile_no">Telefon *</label>
<input class="" name="mobile_no" id="mobile_no" type="tel" required/>
</div>
<div class="large-12 columns text-center">
<input type="submit" name="submit" value="MODTAG UFORPLIGTENDE TILBUD" class="submit-pris">
</div>
</div>
答案 0 :(得分:1)
添加括号并使用intval()
功能
像这样:echo "<p><strong>Your price: </strong>" . (intval($_POST['vindue1']) * intval($_POST['quantity'])). " Kr. </p>";