andrew6607 Posted April 4, 2008 Share Posted April 4, 2008 Hello, I am trying to set up a System For A Virtual Airline. When someone enters the amount of hours they did on a flight and then it ads it to the currents hours in the database. Example.. They currently have 200 Hours logged. And They submit a report with 2.8 Hours. So then the table would be updated and then say they have 202.8 Hours. Thanks! Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/ Share on other sites More sharing options...
Northern Flame Posted April 4, 2008 Share Posted April 4, 2008 so whats your question? Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/#findComment-509625 Share on other sites More sharing options...
andrew6607 Posted April 4, 2008 Author Share Posted April 4, 2008 The Questions is.. How Would i get the 2.8 Hours into the database so it would equal 202.8? Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/#findComment-509642 Share on other sites More sharing options...
Northern Flame Posted April 4, 2008 Share Posted April 4, 2008 run a mysql_query to select the hours, mysql_query("SELECT hours FROM table_name") and then add 2.8 to it. Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/#findComment-509652 Share on other sites More sharing options...
andrew6607 Posted April 4, 2008 Author Share Posted April 4, 2008 Yea i know about the query. But how would i add the hours to the table. Thats What IM Wondering! Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/#findComment-509656 Share on other sites More sharing options...
Northern Flame Posted April 4, 2008 Share Posted April 4, 2008 $hours = mysql_fetch_array($query); $new_hours = $hours['hours'] + 2.8 mysql_query("UPDATE table_name SET hours = '$new_hours'"); (might need to add a WHERE in there if you have multiple rows and only want one row to be affected) Link to comment https://forums.phpfreaks.com/topic/99620-solved-mysql-help/#findComment-509658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.