You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP实现:查询注册项并禁用当周已提交报告的选项

注册项选择框实现需求与尝试方案

尝试的SQL查询方案

用于返回所有reportDate为当前周的注册记录:

SELECT * 
FROM registrations 
LEFT JOIN reports on registrations.registration=reports.registration
WHERE  reports.reportDate 
  between cast(timestampadd(SQL_TSI_DAY, -(dayofweek(curdate())-2), curdate()) as date) 
  and cast(timestampadd(SQL_TSI_DAY, 7-(dayofweek(curdate())-1), curdate()) as date)

待实现的PHP逻辑需求

需要完成以下3项功能:

  • 从Registrations表获取所有registration字段值;
  • 检查这些注册项是否在Reports表中存在reportDate为当前周(周一至周日,本次测试周为8月26日至9月1日)的记录;
  • 通过PHP输出HTML的select输入框,显示所有注册项,其中当周有对应报告的项设为可见但禁用。

数据表数据示例

Registrations表

idregistration
1EXAMPLE
2EXAMPLE2
3EXAMPLE3

Reports表

idregistrationreportDate
1EXAMPLE2024-08-19
2EXAMPLE2024-08-22
3EXAMPLE22024-08-22
4EXAMPLE32024-08-22
5EXAMPLE2024-08-27
6EXAMPLE32024-08-27

预期输出效果

根据当前周数据,EXAMPLE和EXAMPLE3因存在当周报告需设为禁用,EXAMPLE2可正常选择,最终输出的HTML代码如下:

<select oncopy="return false" id="inspectReg" name="inspectReg" class="reg-control">
<!-- 可用foreach或while循环实现 -->
<option value="EXAMPLE" disabled>EXAMPLE</option> <!-- 8月27日有记录,故禁用 -->
<option value="EXAMPLE2">EXAMPLE2</option> <!-- 当前周无对应记录 -->
<option value="EXAMPLE3" disabled>EXAMPLE3</option> <!-- 8月27日有记录,故禁用 -->
</select>

内容的提问来源于stack exchange,提问作者George Richardson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 23:22:17