我正在尝试使用此处制作表格,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 天,如果我明天通过那次考试,我会很高兴 :)