你好我有一個問題,選擇一個值形成我的表到在PHP中的變量,這樣我可以計算的東西選擇值到
這裏的成本利用表單輸入變量是我到目前爲止的代碼我希望能夠從表C_price
中選擇「成本」值,其中值I_type
和a_type
匹配
例如表結構看起來像這樣
ID=1,A_type=line,I_type=Head,cost=5
如果我輸入線和頭 我需要能夠在獲得價值5到古老的,我可以在計算中使用,並插入到另一個表AKA表單上我需要獲得成本到一個變量在某種程度上
以下是我的嘗試,我需要幫助即時通訊新的這一切,請幫助
$E_C;
$T_cost = "1";
$date = date("d.m.y");
$name = $_POST["from"];
$email = $_POST["email"];
$ref = $_POST["link"];
$i_type = $_POST["i_type"];
$a_type = $_POST["a_type"];
$extra = $_POST["extra"];
$des = $_POST["description"];
$BG = $_POST["BG"];
$bg_type = $_POST["BGtype"];
$msg = $_POST["message"];
$auto_reply = ("thanks for the email we will get back to you as soon as we can about the cost and how you can pay");
$msg = wordwrap($msg, 70);
$host = "localhost";// hostname
$USER = "root";// username
$PASS = "Password";// password
$DBNAME = "andrea";// databace name
$tbl_name = "c_price";// table name
$con = mysqli_connect("localhost", $USER, $PASS, $DBNAME)or die("mySQL server connection failed");
$all = "SELECT cost FROM C_price WHERE a_type=$a_type,i_type=$i_type";
$result = mysqli_query($con,$all) or die("Error getting total storse");
while($row = mysqli_fetch_array($result))
{
echo $row['cost'];
}
if ($a_type = 'waist' && $extra='Y')
{
$E_C = $cost * .3;
}
elseif ($a_type = 'knee' && $extra='Y')
{
$E_C = $cost * .35;
}
elseif ($a_type ='full' && $extra='Y')
{
$E_C = $cost * .4;
}
else
{
$E_C = 0;
}
$T_cost = $cost + $E_C;
if ($BG = 'y')
{
$T_cost = $T_cost + 10;
}
詩對不起我的拼寫IM dislexic和spell feneticaly – crages1111 2014-09-24 05:18:51
混合'mysqli'和'mysql'是錯誤的 – 2014-09-24 05:20:40
'a_type = $ a_type'應該是'a_type ='$ a_type'' – Anthony 2014-09-24 05:24:27