0

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_result = 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?

1
  • "How can I edit this to list the number of events" - instead of the current output or in addition to? Commented Aug 21, 2011 at 16:48

4 Answers 4

2
$day_events = "SELECT COUNT(*) FROM tbl_events WHERE day='".$day_id."'";
print mysql_result(mysql_query($day_events),0)
Sign up to request clarification or add additional context in comments.

Comments

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

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

Comments

1
echo mysql_num_rows($evenets_result);

Looking for this?

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.