从数据库到单选按钮选择价格

时间:2012-11-25 12:08:17

标签: php mysql

我正在尝试使用php在此处制作表单,但我被卡住了! 我已经制作了一个表单,其中包含分配给单选按钮的所有类型的food课程:

<form action="proberen.php" method="post">

<label>Klantnummer</label>
<input type="text" name="txtklantnr" /><br/>

<label>Voornaam</label>
<input type="text" name="txtfname" /><br/>

<label>Achternaam</label>
<input type="text" name="txtlname" /><br/>

<br/>
<br/>
---------------------
<br/>
Menu
<br/>
---------------------
<br/>
<br/>
<label>first dish</label><br/><br/>

<label>Soup</label>
<input type="radio" name="txtvoor"  checked="checked" value="soup" />
<label>8 euro</label><br/>

<label>Slaatje</label>
<input type="radio" name="txtvoor" value="sla"  />
<label>6 euro</label><br/><br/>

<label>main dish</label><br/><br/>

<label>Kip met Friet</label>
<input type="radio" name="txthoofd"  checked="checked" value="kip" />
<label>12euro</label><br/>

<label>Worst met Patat</label>
<input type="radio" name="txthoofd" value="worst" />
<label>10euro</label><br/><br/>

<label>Dessert</label><br/><br/>

<label>Ijs</label>
<input type="radio" name="txtna"  checked="checked" value="ijs" />
<label>4euro</label><br/>

<label>Taart</label>
<input type="radio" name="txtna" value="taart" />
<label>5 euro</label><br/><br/>

<input type="submit" value="Bereken Totaal" />

</form>

我创建了一个包含所有收件人的数据库和一个包含所有价格的数据库 这是我的php:

<?php
$fldklantnr = $_POST["txtklantnr"];

$fldvnaam = $_POST["txtfname"];
$fldanaam = $_POST["txtlname"];

$fldvoor = $_POST["txtvoor"];
$fldhoofd = $_POST["txthoofd"];
$fldna = $_POST["txtna"];

$db = MySql_connect("localhost","root","root");
Mysql_select_db("menutest",$db);

$result=("select * from tblmenu where fldvoor='$fldvoor'");
$resultb=("select * from tblmenu where fldhoofd='$fldhoofd'");
$resultc=("select * from tblmenu where fldna='$fldna'");

$fldtotaal = $resultd + $resulte+$resultf;


    echo "Beste $fldvnaam $fldanaam.<br/>U heeft het volgende besteld:<br/>";
    echo " $fldvoor <br/>"; 
    echo " $fldhoofd <br/>" ;
    echo " $fldna <br/>" ;
    echo "Het totaal bedrag is $fldtotaal euro. <br/>Bedankt voor uw bestelling.";

$sql="insert into tblmenu values('$fldklantnr','$fldvnaam','$fldanaam','$fldvoor','$fldhoofd','$fldna','$fldtotaal')";

MySql_query($sql,$db);

?>

现在我要计算订购菜单的总和:价格在我的tblprijzen中,我试过这样的事情:

if ($result==soup){
    $resultd=("select *from tblprijs where fldsoup='fldsoup'");
}
else{
    $resultd=("select *from tblprijs where fldslaatje='fldslaatje'");
}

if ($resultb==kip){
    $resulte=("select *from tblprijs where fldkip='fldkip'");
}
else{
    $resulte=("select *from tblprijs where fldworst='fldworst'");
}

if ($resultc==ijs){
    $resultf=("select from tblprijs where fldijs='fldijs'");
}
else{
    $resultf=("select from tblprijs where fldtaart='fldtaart'");
}

$totaal = $resultd + $resulte + $resultf;

但它没有做任何事:(

试着让这项工作超过2天,如果我明天通过考试,我会很高兴:)

0 个答案:

没有答案