在两个日期时间之间获取查询

This is the code I have:

$qry = "SELECT * 
          FROM parties 
         WHERE schoolid = $schoolid AND 
         WHERE timestart BETWEEN '$dateStart 00:00:00' AND '$dateEnd 23:59:59' 
      ORDER BY timestart, attending";

This is what I get when I echo the query:

  SELECT * 
    FROM parties 
   WHERE schoolid = 100 AND 
   WHERE timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59' 
ORDER BY timestart, attending

It doesn't work. And when I manually run the code in PHPMyAdmin it just tells me I have an error in my syntax. What is wrong?

you are typing WHERE twice and it has to be only once.

should be like this:

  SELECT * 
    FROM parties 
   WHERE schoolid = 100 AND 
         timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59' 
ORDER BY timestart,attending
  SELECT * 
    FROM parties 
   WHERE schoolid = 100 AND 
         timestart BETWEEN '2013-08-13 00:00:00' AND '2013-09-12 23:59:59' 
ORDER BY timestart, attending

Remove the AND WHERE, it's syntactically incorrect - the correct one is a lonely AND on that spot.

There should be only one WHERE in query unless subquery is used.