0

I have database with Name, email, joindate and my Query is

$name=$_POST['txtname'];
$email=$_POST['txtemail'];
$date = date("Y/m/d");

INSERT INTO member (name,email,joindate) VALUES ('$name', '$email', '$date')

What should be the output query to get all data by month?

Edited by abhilashrajrs: spell mistake

3
Contributors
3
Replies
25
Views
3 Years
Discussion Span
Last Post by pritaeas
0

Try this

<?php
$result = mysql_query("SELECT   DATE_FORMAT(`joindate`,'%m/%Y') AS MonthYear   FROM  member GROUP BY YEAR(joindate), MONTH(joindate);");

while($row = mysql_fetch_array($result))
  {
     echo '<h2>'.$row['MonthYear'].' </h2>';
     $resultTwo = mysql_query("SELECT   *  FROM  member WHERE DATE_FORMAT(`joindate`,'%m/%Y') = '{$row['MonthYear']}';");
     while($rowTwo = mysql_fetch_array($resultTwo)) {
        echo '<p>Member: '.$rowTwo['name'].' </p>';
        echo '<p>Email: '.$rowTwo['email'].' </p>';
        echo '<p>Joindate: '.$rowTwo['joindate'].' </p><hr />';
     }
  }
?>
0

its showing blank

There's probably an error somewhere. Check your error_log, or add error checking to your query.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.