LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-01-2008, 09:31 AM   #16
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Original Poster
Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491

Quote:
I'd have the system read the current system date automatically. Stops the 'volunteers' fiddling the dates
They can't fiddle with the dates. I'm not explaining very well based on the last two posts. I used win32sux script from post #7 so that when a volunteer logs in by name, a unix timestamp is automatically posted in the mysql table. I wasn't aware that something like win32sux last suggestion was a possibility so I will do some research on that.

Quote:
automatically setting the time to midnight in the timestamp generated from your search form's input, and then telling MySQL to only show you records with timestamps between "that" and "that plus 86400"
I then added another row to the table for yearmonth. When volunteers login they are asked to enter the date. This is not used to determine hours but only for search purposes and is not an output in the scripts. It's a little cumbersome but, until I am able to implement win32sux suggestion, I guess this will work.

Thanks for your suggestion.

Last edited by yancek; 10-01-2008 at 03:08 PM.
 
Old 10-01-2008, 09:49 AM   #17
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Yeah, I'd recommend you start working to completely rid yourself of any non-timestamp storage in your database. That thing about having the guys enter dates on their own in order to use that for search later sounds really unnecessary, error-prone, and cumbersome IMHO. If you need help implementing the suggestion I gave you about "midnight" just ask.

Last edited by win32sux; 10-01-2008 at 04:52 PM. Reason: Removed request to change certain CODE tags to QUOTE.
 
Old 10-01-2008, 04:25 PM   #18
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Original Poster
Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
I agree that having non-timestamp storage is obviously duplicative and a little cumbersome. I tried it on a test machine to see if it would output the data I wanted the way I wanted and it did.

I do need help implement your suggestion about a "midnight" entry. I understand the concept but am not sure how to implement it. I did a little googling earlier but haven't found anything satisfactory yet. Will keep trying and I would appreciate any help.

Thanks.
 
Old 10-01-2008, 04:43 PM   #19
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Well, the way I picture it is like this example:
PHP Code:
$Day   $_POST[day];
$Month $_POST[month];
$Year  $_POST[year];

$SearchDateStart mktime(0,0,0,$Month,$Day,$Year);
$SearchDateStop  $SearchDateStart 86400
You just make sure the search form submits all three POST values as numericals.

Then the MySQL query could be like:
PHP Code:
$result mysql_query("SELECT * FROM TimeSheet
WHERE Date >= 
$SearchDateStart AND Date < $SearchDateStop"); 
Give it a shot and see if it works (I haven't tried it).

Last edited by win32sux; 10-01-2008 at 04:56 PM.
 
Old 10-02-2008, 04:26 PM   #20
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Original Poster
Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
I've obviously got something wrong in the script. Database name 'timesheet', table 'hours', two fields 'name' and 'datetime'. Here's the php script I have:

PHP Code:
<?php
mysql_connect
("localhost","username","password");
mysql_select_db("timesheet");
$Day $_POST['day'];
$Month $_POST['month'];
$Year=$_POST['year'];
$SearchDateStart mktime(0,0,0,$month,$day,$year);
$SearchDateStop $SearchDateStart 86400;
$search-$_POST["search"];
$result mysql_query("SELECT * FROM hours WHERE datetime >= $SearchDateStart AND datetime < $SearchDateStop");
echo 
"<table>";
while(
$row mysql_fetch_array($result))
   {
     
$HumanDateTime date("F j, Y (g:i A)",$row['datetime']);
     echo 
"<tr><td>" $row['name'] . "</td>";
     echo 
"<td>" $HumanDateTime "</td></tr>";  
   }
echo 
"</table>";
?>
I understand how the part of the script you posted in your last post would work but don't see how the script could work. Something missing and I don't know what it is. I'm a little out of my depth here.

Last edited by yancek; 10-02-2008 at 05:41 PM.
 
Old 10-02-2008, 05:19 PM   #21
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Variable names are case-sensitive. The values you are feeding the mktime() function in your post above aren't the ones which were submitted via POST. Once you fix that you should verify that your form is submitting the POST values properly (you can test by echoing them on the search result page) before focusing on the query part.

BTW, what's this about:
PHP Code:
$search-$_POST["search"]; 

Last edited by win32sux; 10-02-2008 at 06:25 PM.
 
Old 10-02-2008, 06:10 PM   #22
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Original Poster
Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
OK. Got it working. Thanks for your help. The entry below was part of a different search script I use when I was trying different things to get this to work, forgot to delete.

PHP Code:
$search-$_POST["search"]; 

Last edited by yancek; 10-02-2008 at 06:12 PM.
 
Old 10-02-2008, 06:24 PM   #23
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by yancek View Post
OK. Got it working. Thanks for your help.
You're welcome. Was the case sensitivity the problem or was it something else?
 
Old 10-03-2008, 04:29 PM   #24
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Original Poster
Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
It was the case sensitivity in variable. Thanks again.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Volunteer Economy LXer Syndicated Linux News 0 02-11-2008 09:40 AM
Volunteer/Grid Computing Issue hamtavs General 9 03-15-2007 06:04 AM
Where to find volunteer work on linux bahadur Linux - Software 11 09-30-2005 04:47 AM
Volunteer needs help keeping track. mimsmall Linux - Software 1 10-10-2004 02:03 PM
newbie c programming volunteer clancyian Programming 1 01-08-2004 03:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration