hello
i am trying to interrogate the database to count the number of visitors between 2 specific dates each year 08 Dec YYYY until 07 Dec YYYY. each year it will change ( hence the variable )
ijust cant figure out the rest of the code.
the field is a date input in varchar eg 25-12-2011. the end product does not give a result that compares dates.
the echoes both produce the right format,
where am i going wrong?
thanks ever so much.
i am trying to interrogate the database to count the number of visitors between 2 specific dates each year 08 Dec YYYY until 07 Dec YYYY. each year it will change ( hence the variable )
ijust cant figure out the rest of the code.
<?php
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$thisyr = DATE("08/12/Y");
$lastyr = strtotime ( '-366 day' , strtotime ( $thisyr ) ) ;
$lastyr = date ( 'd/m/Y' , $lastyr );
$result = mysql_query("SELECT * FROM table WHERE field BETWEEN '<?php date($thisyr) ?>' AND '<?php date($lastyr) ?>'");
$num_rows = mysql_num_rows($result);
echo $num_rows . ' visitors';
?>
</p>
<?php
echo date($thisyr);
?>
</p>
<?php
echo date($lastyr);
?>
the field is a date input in varchar eg 25-12-2011. the end product does not give a result that compares dates.
the echoes both produce the right format,
where am i going wrong?
thanks ever so much.