• 0

PHP, Record expiration


Question

Basically I do not want the data to show from within the SQL database if the date has expired. What I MAY have to do is change my date format but want to see if someone had suggestions on what I could be doing wrong or leaving out.

So right now I have the user recording their timeout of the data. The format is saved like this: YYYY-MM-DD

Then my code to display the records are as follows:

$current = date("Y-m-d");

$b = "SELECT * FROM mytable WHERE timeout > '%$current%' ORDER BY date ASC";

I've tried both combinations of > or <. < displays nothing at all. I have two records for testing. One set for the 31st and one for the 23rd. So obviously that date format is not being read correctly by the > or <.

Suggestions?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Well I don't know why, but I always figure out stuff AFTER I post it here. I've been working on this for a few days...

Maybe I should fake post to notepad as typing out my requests seems to help.

What I ended up having to do is this:

$current = date("Ymd");

$b = "SELECT TOP 5 * FROM mytable WHERE frntpg=1 AND timeout <= $current ORDER BY date ASC";

I removed the - from my date.. however that did not make the difference.

I removed the '% %' from around my variable and that fixed the issue.

Link to comment
Share on other sites

  • 0

Yeah, I get the same as you. You ask a question and then realise the answer. I tend when I get stuck, take a step back, go get a drink, get some fresh hair/clean head and go back and look at it logically, and run it through step by step. Works for me, might work for you :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.