Current location: Hot Scripts Forums » Programming Languages » PHP » searching database records using time()


searching database records using time()

Reply
  #1 (permalink)  
Old 03-17-04, 03:21 PM
standXalone standXalone is offline
Newbie Coder
 
Join Date: Mar 2004
Location: ontario canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
searching database records using time()

i have a form set up, and have the option for users to search the user's table for the last time a member has updated their profile. i have the search options as:

<FORM NAME="search" ACTION="members.php" METHOD="GET">
<select NAME="last_update" class="select" style="width:121px;">
<option VALUE="today">Updated Today</option>
<option VALUE="yesterday">Updated Yesterday</option>
<option VALUE="last_week">Last 7 Days</option>
</select>&nbsp;<INPUT type="submit" value="Go" style="font-size: 7pt; font-family: Verdana; background-color: #E9E9E9"><input type="hidden" name="last_update" value="1"></form>

now, the sql for this is as follows...

if (isset($_GET['last_update'])) {

if ( $HTTP_GET_VARS['last_update'] == "today" )
{
$length = 1;
}
else if ( $HTTP_GET_VARS['last_update'] == "yesterday")
{
$length = 2;
}
else if ( $HTTP_GET_VARS['last_update'] == "last_week")
{
$length = 7;
}

$time_period = time() - ($length * 86400);
$links_sql .= ' WHERE user_update >= '. $time_period.' ';
$total_records_sql .= ' WHERE user_update >= '. $time_period.' ';
};

on submit, it is not returning any values. i commented our the $time_period variable and recieved this
today - 1079556944
yesterday - 1079556959
a week - 1079556973

can anyone help? i really need to get this finished
Reply With Quote
  #2 (permalink)  
Old 03-17-04, 04:38 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Hey,
Coudl you tell me first in what way is the time stored in the database (seconds, minutes or w/e)
Reply With Quote
  #3 (permalink)  
Old 03-17-04, 06:18 PM
standXalone standXalone is offline
Newbie Coder
 
Join Date: Mar 2004
Location: ontario canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
it is being stored as time() everytime the update profile page is submitted
Reply With Quote
  #4 (permalink)  
Old 03-17-04, 08:04 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Angry

*slaps him self*
*sec ill get back to you-- i made a mistake and i can't seem to delete posts on this from [gets mad]*

Simple..
Code:
<INPUT type="submit" value="Go" style="font-size: 7pt; font-family: Verdana; background-color: #E9E9E9"><input type="hidden" name="last_update1" value="1">
is the same name as the drop down menu. change it to something else ;D

Last edited by Infinite_Hackers; 03-17-04 at 08:14 PM.
Reply With Quote
  #5 (permalink)  
Old 03-18-04, 09:30 AM
standXalone standXalone is offline
Newbie Coder
 
Join Date: Mar 2004
Location: ontario canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
hey again... i got it almost working, however, when i do a search for today, or yesterday, i get results from a couple different days, not just from what im looking for... here is the code i have so far

if (isset($_GET['last_update']))
{
if ( $HTTP_GET_VARS['last_update'] == "today")
$length = 1;
else if ( $HTTP_GET_VARS['last_update'] == "yesterday" )
$length = 2;
else if ( $HTTP_GET_VARS['last_update'] == "last_week" )
$length = 7;

$time_period = time() - ($length * 86400);
$links_sql .= ' WHERE user_update >= '. $time_period.' ';
$total_records_sql .= ' WHERE user_update >= '. $time_period.' ';
}
Reply With Quote
  #6 (permalink)  
Old 03-18-04, 11:32 PM
standXalone standXalone is offline
Newbie Coder
 
Join Date: Mar 2004
Location: ontario canada
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
can anyone help? it would be much appreciated
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching an XML database bumpdiggler Script Requests 1 03-02-04 07:31 PM
Searching through a database for a password philkills ASP 1 02-13-04 08:25 PM
Sorting database records (Help) v1brazy ASP 3 01-28-04 07:47 PM
records from database with the link sasi ASP 2 09-24-03 04:41 AM


All times are GMT -5. The time now is 10:20 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.