在php中获取当前数据

I have a table, in mysql and it has a column called Date.. I want to take from the database all the rows with date the same as current date. How can I do this? please help me.

I am trying like below:

$sql=mysql_query(select * from table where Date=getCurrentDate());

But it does not function..Please help me

I update my code like this:

$aktivitetet=mysql_query("select * from aktiviteti where Date=CURDATE())");

$rai=mysql_num_rows($aktivitetet);

if($rai>0)
{echo"There are activities on that date";}
else
{echo "There are no activities";}

but I have this error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\agenda\home.php on line 125

Assuming the date column is of the date type, use CURDATE()

$sql=mysql_query(select * from table where Date=CURDATE());

If that column is a datetime type use Date(), too:

$sql=mysql_query(select * from table where Date(`Date`)=CURDATE());

You need to pass a string to the mysql_query method:

$sql=mysql_query('select * from table where Date=CURDATE()');
$now = new DateTime();
$now->format('Y-m-d H:i:s');    // MySQL datetime format
$now->getTimestamp();

$sql=mysql_query("select * from table where Date=".$now);

Just incase you have only just started developing your application you should look into using mysqli instead of mysql (mysql will be gone as of php 5.5.0). If not you should just be able to use "Date=CURDATE".


$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));

$query = "SELECT * FROM table WHERE Date=CURDATE()" or die("Error" . mysqli_error($link));

$result = $link->query($query);

while($row = mysqli_fecth_array($result)) {
  echo $row["Date"] . "<br>";
}

check your "Date" type is it the same type with the current date type that you get from "getCurrentDate()" function, you will need to set your Date format for your convenience.