1
我想使貨幣轉換器。如何使用字符串值
$number1="";
$number3="";
<form method="POST">
<select id="dc1" name="dc1">
<option value="9777.31">SGD</option>
</select>
<input type="text" name="text1" value="<?php echo $nilai1?>">
<select id="dc2" name="dc2">
<option value="13190" >USD</option>
<input type="submit" name="calculate" value="calculate">
</select>
</form>
<?php
if(isset($_POST['calculate']))
{
if($_POST['dc1'] && $_POST['dc2'])
{
$number1 = $_POST['text1'];
$one = $_POST['dc1'];
$two = $_POST['dc2'];
$x = $number1/($two/$one);
$number3 = $x;
}else{
$number3 = "fail";
}
}
?>
<input type="text" name="text2" value="<?php echo $number3?>">
它確定這些代碼,但是當我試圖改變這樣的?
$number1="";
$number3="";
$test=9777.31;
<form method="POST">
<select id="dc1" name="dc1">
<option value="<?php $test?>">SGD</option>
</select>
的$number3
結果是"fail"
,其我的代碼那麼糟糕嗎?或者我忘了什麼?
對於你有一個'select'塊內的'input'標籤開始。並且您擁有PHP代碼之外的PHP代碼。 –