php - 如何使用 php 在输入标签中使用条件?
问题描述
如果特定条件为真,则将输入字段设为只读。
$todayDate = date('Y-m-d');
这是条件
$row["date"] == $todayDate (make input readonly true otherwise false)
while($row = $result->fetch_assoc()) {
$output .= '
<tbody><tr>
<td>'.$row["date"].'</td>
<td><input type="text" value = "'.$row["actual_closing_balance"].'"></td>
</tr>
</tbody>';
}
解决方案
做这个:
$readonly = '';
if($row['date'] == $todayDate){
$readonly = 'readonly';
}
'<input type="text" value = "'.$row["actual_closing_balance"].' '.$readonly.' />';
推荐阅读
- javascript - 使用 Yup 和 react-hook-form 在多个字段的表单级别进行验证
- pandas - Pandas 使用 XLSX Writer 表现出色 - 恒定内存/内存中
- reactjs - 使用 firebase 的 rbac 规则
- python - 使用 cythonize 命令编译会抛出错误
- cuda - 有没有办法在减少时减少来自syncthreads()的停顿延迟?
- java - 元素未添加到 ArrayList Java - Android
- python - 将数据框插入具有不同列名的数据库表
- php - yii2 bootstrap 4 没有在 ajax 上突出显示错误
- javascript - Chrome 扩展缺少 Set-Cookie 标头
- amazon-rds - 带有 AWS RDS 的 Spring Cloud AWS