Jump to content

[solved]sql and time <=


Craig Hopson
 Share

Recommended Posts

hi guys a simple one for you i cant get my head round it this is what i have time is stored as "time()" in database when members signup along with ther name now what i want is to show $row['name'] of all members that are 1 week old

$t = time()-604800;$result = mysql_query("SELECT * FROM members WHERE time <= $t");while($row = mysql_fetch_array($result))  {echo $row['name'];   }

Thanks

Edited by Craig Hopson
Link to comment
Share on other sites

It should be greater than.

$result = mysql_query("SELECT * FROM members WHERE time >= $t");

edit: I think you need to clarify 1 week old. Do you mean 1 week old and newer, older than 1 week, or exactly 1 week old?

Edited by thescientist
Link to comment
Share on other sites

ok. so then what's your question then? Do you know what the operators mean?http://www.w3schools.com/sql/sql_where.asp It seems like a simple case of using if/else to check against a basic conditional.

Link to comment
Share on other sites

It should be greater than.
$result = mysql_query("SELECT * FROM members WHERE time >= $t");

edit: I think you need to clarify 1 week old. Do you mean 1 week old and newer, older than 1 week, or exactly 1 week old?

AND IT WOULD BE OLDER THAN 1 WEEK
Link to comment
Share on other sites

AND IT WOULD BE OLDER THAN 1 WEEK
easy spud. That was a post/edit from 3 hours ago. you might want to chill out if you want people to help you. So again, you know the time in the database needs to be greater than the time today minus a week if you want to contact them. Work with that and show us what you've come up with. Write some conditionals out, debug your code, and check your logic. Edited by thescientist
Link to comment
Share on other sites

SOLVED

$t = time()-604800;$result = mysql_query("SELECT * FROM members WHERE time < $t");while($row = mysql_fetch_array($result))  {echo $row['name'];   } 

Edited by Craig Hopson
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...