dongyou6909
2013-11-13 10:30
浏览 17
已采纳

Php - 按天记录的组记录

I have a following table:

  CREATE TABLE IF NOT EXISTS "visits" ( 
  "id" int(10) unsigned NOT NULL AUTO_INCREMENT,
  "start" datetime NOT NULL,
  "finish" datetime NOT NULL,
  "name" varchar(50) NOT NULL,
  PRIMARY KEY ("id")
)

And I would like to display visits for next 2 days as shown in the following code:

<div id="day>Today</div>
<a href="#">VISIT NAME</a>
<a href="#">VISIT NAME</a>
<a href="#">VISIT NAME</a>
<div id="day>Tomorrow</div>
<a href="#">VISIT NAME</a>
<a href="#">VISIT NAME</a>
<div id="day>15-11-2013</div>
<a href="#">VISIT NAME</a>

At this moment I have only this I'm looking for PHP code :) At this moment I have only:

$link=mysql_query('select count(*), DATE_FORMAT(start,"%Y-%m-%d") as start FROM visits GROUP BY start');
            while($row=mysql_fetch_array($link))
            {
            echo'<div id="day">'.$row['start'].' '.$row['count(*)'].'</div>';
            }

but that show only

<div id="day>Today 3</div>
<div id="day>Tomorrow 2</div> 
<div id="day>15-11-2013 1</div>

Thanks in advance for your help.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题