php - 我选择时选项中的选择
问题描述
当我在选项中选择“事件赞助”然后运行代码时,我对编码有疑问。if()
当我在选项中选择“活动赞助”时,如何在这里编写代码?下面是我的编码:
<label for="cp2" class="control-label col-lg-4">Merchant</label>
<div class="col-lg-5">
<select class="form-control required" id="branch_id3" name="branch_id3">
<option value="" selected>Please Select</option>
<option id="1"value="1">Event Sponsored</option>
<option id="2" value="2">Normal Merchant</option>
</select>
</div>
<?php
$key_relationship_8[] = 'id_user';
$val_relationship_8[] = convert_db_value($_POST['filter_id2']);
$key_relationship_8[] = 'type';
$val_relationship_8[] = convert_db_value(3);
$key_relationship_8[] = 'id_transaction_main';
$val_relationship_8[] = convert_db_value($record_id2);
$key_relationship_8[] = 'credit';
$val_relationship_8[] = convert_db_value($_POST['sub_total_rm']* (6/100));
$key_relationship_8[] = 'created';
$val_relationship_8[] = convert_db_value($cur_dt);
$key_relationship_8[] = 'createdby';
$val_relationship_8[] = convert_db_value($user_name);
$key_relationship_8[] = 'modified';
$val_relationship_8[] = convert_db_value($cur_dt);
$key_relationship_8[] = 'modifiedby';
$val_relationship_8[] = convert_db_value($user_name);
if(){ //how to code when I select Event Sponsored then run below the code?
$row_insert8 = db_conn_insert('transaction_credit', $key_relationship_8, $val_relationship_8);
$sql_insert8 = $row_insert8['sql'];
$error_insert8 = $row_insert8['error'];
$record_id8 = $row_insert8['record_id'];
unset($key_relationship_8);
unset($val_relationship_8);
} else ($row_insert8) {
echo 'Saved successfully';
echo $sql_insert8;
}
?>
解决方案
您的Event Sponsored选项的值为1。
我假设您的表单正在使用POST方法。
那么 if 语句可能是 -
if($_POST['branch_id3'] === 1) { }
推荐阅读
- c# - 如何修复从右到左的绘制矩形
- angular - 如何在 Angular 4 的下拉菜单中正确绑定枚举?
- angular - 我可以在 get 方法中更改 Date 类型的属性吗?
- nativescript - 如何在 nativescript 中使用本地插件和云构建?
- sql - 使用链接表oracle匹配多行时如何以嵌套格式显示行
- javascript - 在 Wordpress 中从 JavaScript 更新帖子
- java - hibernate:如何在不检索所有尚未检索的字段的情况下取消代理实体类?
- powershell - PowerShell 运算符,在第一个句点之前选择
- c# - C# Streaming screen over Network
- angular - 在 Angular 6 中链接 APP_INITIALIZER 函数