Home  >  Article  >  Backend Development  >  高分解难题:PHP查询MYSQL数据,记录集怎么特殊显示

高分解难题:PHP查询MYSQL数据,记录集怎么特殊显示

WBOY
WBOYOriginal
2016-06-13 13:47:53767browse

高分解难题:PHP查询MYSQL数据,记录集如何特殊显示!
MYSQL 有个商品价格统计表,如图:


用PHP查询某商品,显示在网页上,查询结果如下:




难点就是如何按照年份、月份显示!难死小弟了,跪求操作语句!

------解决方案--------------------

PHP code
................
$result=mysql_query("select year(addtime) as y,group_concat(jiage) as str from table_name group by year(addtime);");
while($row=mysql_fetch_assoc($result)){
      echo '<tr>';
      echo "<td>$row[y]</td>";
      foreach(explode(',',$row[str]) as $v)
            echo "<td>$v</td>;
      echo '</tr>';
}
............
<br><font color="#e78608">------解决方案--------------------</font><br>
$result=mysql_query("select year(add_date) as y,group_concat(yc_jiage) as str from jiagedata group by year(add_date);") or die(mysql_error());<br><br>贴出提示。
<br><font color="#e78608">------解决方案--------------------</font><br>执行#12楼后提示什么信息。 <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn