我想在 PHP / HTML表中显示这样的MySQL结果.也许以后可以轻松将鼠标悬停在每种植物的信息上.
+-----------------------------------------------------------+
|category1 ¦ category2 ¦ category3 ¦ category4 ¦ category5 ¦
+-----------+-----------+-----------+-----------+-----------+
| plantName ¦ plantName ¦ plantName ¦ plantName ¦ plantName ¦
| plantName ¦ plantName ¦ plantName ¦ plantName ¦ plantName ¦
| plantName ¦ plantName ¦ ¦ ¦ ¦
| ¦ plantName ¦ ¦ ¦ ¦
| ¦ plantName ¦ ¦ ¦ ¦
+-----------+-----------+-----------+-----------+-----------+
首先,我根据海拔和降雨值选择植物.
$sql = mysql_query("SELECT * FROM `plants_tb`
WHERE $elevate>= elevationLOW && $elevate<= elevationHI &&
$rainfall>= rainfallLOW && $rainfall<= rainfallHI ORDER BY commonNames ASC");
$plant = 'commonNames';
$elevationH = 'elevationHI';
$elevationL ='elevationLOW';
$rainfallL ='rainfallLOW';
$rainfallH ='rainfallHI';
$species ='species';
echo "
Name | Category |
---|
while($row = mysql_fetch_array($sql)){
echo "
" . $row[$plant] . "" . $row['heightHI'] . "";}
echo "
";现在,我需要按高度类别在列中显示它们.也许我应该为所选植物制作一个临时表,然后对其进行分类,然后在列中显示它们?
这是我的分类想法.我知道代码之间的错误是不正确的,但我指出了这一点.
$sql="SELECT tree_height FROM $Elevation_Rainfall_list;
WHERE tree_height
BETWEEN 1 AND 7 = $Category1
BETWEEN 7 AND 15 = $Category2
BETWEEN 15 AND 30 = $Category3
BETWEEN 30 AND 9999 = $Category4
if not = $Category5
mahalo的支持!