我在数据库中有一个表,名为自定义字段类型。如果这匹配“textfield”,我想回显一个文本框,如果它匹配“textarea”,我想回显一个文本区域。PHP - 如何检查变量是否匹配数据库条目?
有人能让我知道我在下面做错了什么吗?
<?php if($this->item->custom_field_type1 == 'textfield') {
echo 'this is a text field';
}
?>
我在数据库中有一个表,名为自定义字段类型。如果这匹配“textfield”,我想回显一个文本框,如果它匹配“textarea”,我想回显一个文本区域。PHP - 如何检查变量是否匹配数据库条目?
有人能让我知道我在下面做错了什么吗?
<?php if($this->item->custom_field_type1 == 'textfield') {
echo 'this is a text field';
}
?>
该解决方案可以帮助你
<?php if($this->item->custom_field_type1 == 'textfield') {
echo '<input type="text">';
}
if($this->item->custom_field_type1 == 'textarea') {
echo '<textarea></textarea>';
}
?>
<?php echo ($this->item->custom_field_type1 == 'textfield'?'<input type="text" />':'<textarea></textarea>'); ?>
检查,如果($这个 - >用品 - > custom_field_type1 == '文本') –