php - 从 MySQL 中选择不同的选项
问题描述
我有从 MySQL 表中选择选项的表单。因为我想要唯一的选项,所以我添加了 SELECT DISTINCT... 但我有如下值: R15 和 R15C 现在我想将这两个组合到只有 15 显示在选择选项中?
当前代码:
$result = $conn->query("SELECT DISTINCT diameter FROM tires WHERE cat = 'cars' ORDER BY diameter ASC"); while($rows = $result->fetch_assoc()){ $diameter = $rows['diameter']; ?>
<option value="<?php echo $diameter; ?>"><?php echo $diameter; ?></option>
解决方案
我刚刚添加了它以使其正常工作
AND premer NOT LIKE '%C%'
推荐阅读
- powershell - 如何提高目录创建速度
- android - 未使用 Room 的实体自动生成主键
- javascript - 如何在div的边界内对齐文本标题
- css - 如何处理以大百分比(300%)放大的多个屏幕分辨率
- wpf - 在活动窗口或网格内部而不是 MainWindow 上查找控件
- python - 使用 live stereo3d 图像在迷宫中进行路径检测和进展
- javascript - 如何将二进制图像从 json 响应保存到 S3 存储桶
- reactjs - React路由器:构建链接时如何处理match.url中的尾随/?
- c++ - 如何避免使用 C++ 宏重新声明变量
- apache - 在 Kubernetes 中运行简单的 hello world 静态 http 应用程序