mac_shinobi Posted February 6, 2008 Posted February 6, 2008 we have a logging system that logs all the hardware and equipment we have and one section of it is where I have to go around and check the lapsafes around the school. Anyway to cut a long story short In the database I have to manually alter each laptop item in the database to physically change the date to the date that I did the check ( which is a long winded process ) Is there anyway I could have a button on the web front end so that it altered the date for the selected items. Selected items are items that are checked using a check box so that when I click the button it changes the date to todays date ( that does not change ) ie laptop 1 checkbox1 06-february-2008 laptop 2 checkbox2 06-february-2008 laptop 3 checkbox3 06-february-2008 etc etc Alter date <-- click this button so that it puts the above dates in the date column to 06-february-2008 so that it does not link to the system clock so that when I come back tommorow or any time after today the date is still 06-february-2008 and not 07-february-2008 or greater then that ?
Jona Posted February 6, 2008 Posted February 6, 2008 The SQL command you want is something like UPDATE laptoptable WHERE [laptopid]=laptop SET [date]='06/02/2008'; ref: http://www.w3schools.com/sql/sql_update.asp but with out knowing more details, I can't really help any more (table name, schema, sql server type, client language, etc). Cheers Jona
Bromcom_John Posted February 6, 2008 Posted February 6, 2008 If you substitute the date in the above example with GetDate() it would use todays date rather than having to manually edit the date value each time or if you want it to always show the particular date use the above as written. There are a whole slew of Date parameter variables (exact syntax depends on version of SQL your using) that should allow you to get exactly what date format you want too.
Jona Posted February 6, 2008 Posted February 6, 2008 If you substitute the date in the above example with GetDate() it would use todays date rather than having to manually edit the date value each time or if you want it to always show the particular date use the above as written. There are a whole slew of Date parameter variables (exact syntax depends on version of SQL your using) that should allow you to get exactly what date format you want too. getDate works in MSSQL, the my-sql equivlent seems to be curdate(). http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html. But if your doing it from a front-end it maybe easier to use that to generate the current date. To address another point of the OPs, once you write it to the database, it won't automatically update to the system clock so you shouldn't have to worry about that.
mac_shinobi Posted February 6, 2008 Author Posted February 6, 2008 so going from the above info if i used : UPDATE laptoptable WHERE [laptopid]=laptop SET [date]=curdate(); Is that the correct syntax assuming that latoptable is the name of the table and where does each [laptopid] come from ? also what is laptop ? taking into consideration that for example in one lapsafe in the database it pulls up the laptops from the science lapsafe, this has 16 laptops in it. So there will be 16 check boxes ( each check box on the same line as each laptop ) laptop one -- [c] laptop two -- [c] etc where [c] is a physical checkbox where I click the mouse and it checks or unchecks the checkbox. Thanks
Jona Posted February 6, 2008 Posted February 6, 2008 This is all getting rather abstract but in my example laptop was the id of the database record about the laptop I suppose really it should have been in quotes ''. [laptopid] would be the unique identifer (primary key) field of the laptop record in the table laptoptable. Talking about checkboxes isn't that helpful as you need to know what's going on in the underlying database. A checkbox could imply a boolean field so it would be something like update ...... SET [booleanFieldThatIsSourceOfCheckbox]='True'; But you've mentioned date so I think you need to take a look at the underlying database tables. If you look at the state of a specific record first then do the check box and see how the record changes that should give you a good start. Cheers Jona
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now