MYSQL 有个商品价格统计表,如图:
用PHP查询某商品,显示在网页上,查询结果如下:
难点就是如何按照年份、月份显示!难死小弟了,跪求操作语句!
用PHP查询某商品,显示在网页上,查询结果如下:
难点就是如何按照年份、月份显示!难死小弟了,跪求操作语句!
解决方案 »
- Apache php配置 the requested operation has failed
- 把几个数字拆分保存的算法问题
- 关于phpstudy使用问题
- PHP提取字符串中的字符部分
- 请教一个关于php操作mysql的问题,希望大家帮忙。
- 公司急招PHP程序员---北京朝阳小营
- 新配的环境,连接数据库出现错误,希望能等到大家的提示!
- php怎么处理数据量大的xml?
- Call to undefined function: mysql_connect() ,php5+IIS+mySql+win2000
- 关于PHP公网项目获取访问者IP,却只能获取到局域网IP的情况
- 求正则表达式
- 【推荐】写给学历低的web程序员
$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>';
}
............输出一个表格还是div,样式你自己搞定。
我试了一下,上面的语句有语法错误,运行错误,谁能告诉我?提示:Parse error: syntax error, unexpected $end in D:\wamp\www\index.php on line 16
<?php
mysql_connect('127.0.0.1','root','');
mysql_select_db('jiagedata');$result=mysql_query("select year(add_date) as y,group_concat(yc_jiage) as str from jiagedata group by year(add_date);");
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>";
}?>
运行后,提示:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\wamp\www\index.php on line 8
直接使用 php 代码实现时下下策
建议你先创建一个视图
12楼运行后,提示:
Notice: Use of undefined constant str - assumed 'str' in D:\wamp\www\index.php on line 13
2: 当前脚本首行: error_reporting(E_ALL & ~E_NOTICE);