Jump to content

Getting the next weeks deadlines from the database


Go to solution Solved by 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);
?>
Edited by andrew_biggart

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);
?>
  • Solution

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);
?>
Edited by andrew_biggart
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.