Jump to content

Print hours from db to spesified day


pikkue

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/246493-print-hours-from-db-to-spesified-day/
Share on other sites

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.