ProDraz
ProDraz

Reputation: 1281

MySQL + PHP query with date causing issues

I use this code, which should return me total amount (sum) of clients registrered/joined in last 7 days (sun-sat).

  require '../dbconnect.php';

  $result = full_query ('SELECT COUNT(*) FROM tblclients WHERE date between \'' . date ('Y-m-d', mktime (0, 0, 0, date ('m'), date ('d') - 7, date ('Y'))) . '%\' AND \'' . date ('Y-m-d') . '%\'');
  $data = mysql_fetch_array ($result);
  echo $data;

For some reasson, I get no results. Please help.

Upvotes: 0

Views: 69

Answers (2)

user894932
user894932

Reputation:

familarize yourself with the

       now() 

function in mysql

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_now

Upvotes: 1

Ben D
Ben D

Reputation: 14479

For one, you're trying to echo an array. Try print_r($data)

Upvotes: 1

Related Questions