我有一个comboBox,有选项:transpo,meal和medical。我想将值插入到与用户选择的选项对应的列中。 可能吗?
这是我最新的询问。
$conn->query("INSERT INTO expenses
SET employee_id = :emp_id,
client_id = :client_id,
CASE
WHEN :cat == 'transpo' THEN transpo_exp = :worth
WHEN :cat == 'meal' THEN meal_exp = :worth
WHEN :cat == 'medical' THEN medical_exp = :worth");
答案 0 :(得分:0)
please use array [] symbol in select name.
<select name="expenses[]" multiple="multiple">
<option value=""></option>
<option value=""></option>
<option value=""></option>
</select>
and get array variable.
$expenses= $_POST['expenses'];
for($i = 0; $i < count($expenses); $i++){
echo $expenses[$i];
$Qry = mysql_query("INSERT INTO expenses VALUES('$expenses[$i]]')");
}