Reputation: 45
Newbie here. When I put a date ('YYYY-MM-DD') in the WHERE clause, it works great. When I replace it with a variable that is passed from the previous page, the WHERE clause is ignored. Is it because the variable hasn't been created yet?
<?php $name = $_POST["start"]; ?>
$query = "SELECT employees.first, employees.last, employees.street, employees.city,
employees.a, employees.b,
GROUP_CONCAT(empchecks.checknum ORDER BY empchecks.checkdate SEPARATOR '<br /> ') as
checknum,
GROUP_CONCAT(empchecks.checkdate ORDER BY empchecks.checkdate
SEPARATOR '<br /> ')
as checkdate
FROM employees
INNER JOIN empchecks ON employees.enum = empchecks.enum
WHERE empchecks.checkdate >= '$start' GROUP BY empchecks.enum";
Upvotes: 0
Views: 267
Reputation: 97
write this extract($_POST) To be able to use $start instead of $name
Upvotes: 0
Reputation: 68
The variable $start does not exist. Try replacing it with $name and see if it works. You should also use sprintf http://php.net/manual/en/function.sprintf.php to pass in variables for the query instead.
Upvotes: 3
Reputation: 558
Looks like you're assigning $_POST['start']
to $name
and not to $start
which you're refering to later.
Upvotes: 1
Reputation: 2947
Your POST is "start", but you assign it to "name"
So use $name in your SQL...
Upvotes: 0