Top Questions

  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Dec 10, 2016

    MySQL sorting by age if your birthday like this 1974-05-15, 1974-05-28 (YEAR,MONTH,DATE)

    // Check connection
    if (mysqli_connect_errno())
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
    // Perform queries
    $sql="SELECT * FROM $table_name WHERE TIMESTAMPDIFF(YEAR, $column_name, CURDATE()) BETWEEN $age_from AND $age_to";
    // Associative array
    printf ("%s (%s)\n",$row["id"],$row["name"]);
    // Free result set

Add Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.