Jump to content

Getting the next weeks deadlines from the database


andrew_biggart

Recommended Posts

I'm struggling to get my head around the logic of this, and wondering if someone can point me in the right direction.

 

Overview

 

What I'm trying to do is query the database and get all records which have a date which falls within the next week.

 

Can anyone point me in the right direction?

I thought this would do it, but it isn't pulling out any records.

<?php 
   $today  = date("Y-m-d");
   $week   = date("Y-m-d",strtotime("+1 week"));
								
   $sql    = " SELECT * FROM jobsT WHERE job_deadline BETWEEN $today AND $week";
   $result = mysql_query($sql);
?>

School boy syntax error. It's working now.

<?php 
   $today  = date("Y-m-d");
   $week   = date("Y-m-d",strtotime("+1 week"));
								
   $sql    = " SELECT * FROM jobsT WHERE job_deadline BETWEEN '$today' AND '$week'";
   $result = mysql_query($sql);
?>

I'm trying to add an additional parameter to the WHERE statement, which will only select jobs with a status of 'Accepted' and are within the next week.

 

However when I add this parameter, it returns no results. i have checked, and there is definitely jobs which should be show.

 

What am I doing wrong?

<?php 
   $today   = date("Y-m-d");
   $week    = date("Y-m-d",strtotime("+1 week"));
								
   $sql1    = " SELECT * FROM jobsT WHERE job status = 'Accepted' AND job_deadline BETWEEN '$today' AND '$week'";
   $result1 = mysql_query($sql1);
?>

I've re-typed it, and it's working now. I think it might have been a caching issue. Dam Google chrome!

<?php 
   $today   = date("Y-m-d");
   $week    = date("Y-m-d",strtotime("+1 week"));
								
   $sql1    = "SELECT * FROM jobsT WHERE job_status = 'Accepted' AND job_deadline BETWEEN '$today' AND '$week'";
   $result1 = mysql_query($sql1);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.