开发者

Make PHP Script count MySQL results?

I have a webpage that is listing the results of each given day of a month using the following code.

  $day_events = "SELECT * FROM tbl_events WHERE day='".$day_id."'";
  $events_resu开发者_如何学Golt = mysql_query($day_events);
  while($event_row=mysql_fetch_array($events_result)) {
  $calendar.= "<span>".$event_row['event']."</span>";
  }

How can I edit this to list the number of events that are found in the...

SELECT * FROM tbl_events WHERE day='".$day_id."'

...query?


$day_events = "SELECT COUNT(*) FROM tbl_events WHERE day='".$day_id."'";
print mysql_result(mysql_query($day_events),0)


SELECT count(*) FROM tbl_events WHERE day ...

BTW you could simply use mysql_num_rows() from your previous query.


echo mysql_num_rows($evenets_result);

Looking for this?


$events_count = mysql_num_rows(mysql_query($day_events));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜