| |||||||||||
A Really easy project, but need help Posted by tinmanbf (tinmanbf), 10 May 2007 Hi allI'm trying to do a really simple project but I can't get my head around it as I haven't been doing this very long. What I want to do is have a really simple MySQL table, it will just have a field called Time that will contain the time in hours. The idea is to use a form on a website to enter a number (a time in full hours) and then submitting the form will update the time in the database, Counting upwards, or even down. The idea being that the database will allow up to 40 hours of time a week and then once 40 hours are up it will give a message to say no more time avaiable, and also show the time left on the form webpage. At the end of the week the time will reset, or get reset by a command and will start over again. So basically: I need to log time, and I can give 40 hours of task time a week, so I want to be able to get people to enter the amout of time they need in a task, eg lets say some one wants 2 hours, I need this deducted from the 40, because I only have 40 hours of time a week, I need to update this so the people filling out the time, know how much time I have left. so when it goes to 0 I have no more task time left until the next week when it gets reset. I'm sure this is real easy to do, but Im having problems getting my head around it. Can anyone help me on my way?? Thanks Ben Posted by admin (Graham Ellis), 11 May 2007 Ben, are you looking to do this as a web application using something like PHP? MySQL is great for storing and enterring user data but it is program friendly rather than web friendly. I fear that answring your question about the SWL query to change a value would be like describing an engine when you need a whole car at this stage ...Graham Posted by tinmanbf (tinmanbf), 11 May 2007 I'm using php, I am just starting out so haven't got very far, so far I have set up the database table and written a short script, but this doesn't do any calculations as yet and only adds more rows instead of updating one single row:<?php $db_host = "humbug"; $username = "benzen78"; $password = "------"; $DB_name = "benzen78_pn"; $chan = mysql_connect ($db_host, $username, $password); mysql_select_db ($DB_name, $chan); $sql="INSERT INTO Transfer_hours SET Time='$Time' "; mysql_query($sql); echo '<font face="arial,verdana" size=2><B>Hours have been updated!</B><P></font>'; ?> Posted by admin (Graham Ellis), 11 May 2007 I think you want a REPLACE or UPDATE and not an INSERT - have a look at my flashbulb moments page that explains the differences. Posted by tinmanbf (tinmanbf), 11 May 2007 Ok this looks as if I've got a bit further but I'm having a problem displaying my timediff data. I want to show the time that is left on the same page as the form that is filled in, I have been able to display the whole table in the process.php scrpit below, but this isn't what I really want to do, the only data I want to see is the result from the timediff command that I run:Code:
I want to display the result given by running the command above on the same page as my input form. This is the code I have so far in my process.php that the form data is sent to: Code:
Posted by tinmanbf (tinmanbf), 12 May 2007 All sorted, Thanks for you helpThis page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |