pikkue Posted September 5, 2011 Share Posted September 5, 2011 I would like to create function, what prints times to specified day. For example Day time total 1 10 - 12 2 2 0 (or nothing) 3 10 - 12:15 2:15 4 10:30 - 12 1:30 5 10 - 12 2 6 0 (or nothing) 7 0 (or nothing) Time comes from database and there is column for day, starting time (like 10), ending time (like 12:15) and total, calculated, time in db. So day and times come from db. Have thinked this much, but can't figure out how. Quote Link to comment https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/ Share on other sites More sharing options...
codefossa Posted September 5, 2011 Share Posted September 5, 2011 You first need to select the info from the database. $sql = "SELECT * FROM `table_name`;"; $result = mysql_query($sql); All you need, assuming that the 7 days are all that's in the database. Now you just display it. $row['column_name'] while ($row = mysql_fetch_assoc($result)) { echo '<tr><td>' . $row['day'] . '</td><td>' . $row['start'] . '</td><td>' . $row['finish'] . '</td><td>' . $row['total'] . '</td></tr>'; } Assuming you put it in a table to show the results. Just an example, you can change it up however ya like. Quote Link to comment https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/#findComment-1265718 Share on other sites More sharing options...
pikkue Posted September 5, 2011 Author Share Posted September 5, 2011 Haven't tthought of that. Great idea. I don't think I will select all, just what I need, but thanks for that. Quote Link to comment https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/#findComment-1265728 Share on other sites More sharing options...
codefossa Posted September 5, 2011 Share Posted September 5, 2011 Haven't tthought of that. Great idea. I don't think I will select all, just what I need, but thanks for that. Well, I can't see your database so I just made some assumptions. I figure you would have to change it up to suit your needs. GL Quote Link to comment https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/#findComment-1265735 Share on other sites More sharing options...
pikkue Posted September 5, 2011 Author Share Posted September 5, 2011 It's partly in finnish, so it wouldn't be much good for you. I will only select and those what I mentioned. Hard part is to display all days of month, date("n"). That although is a good start. One idea is to set always time on last day of month. Quote Link to comment https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/#findComment-1265754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.