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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.