473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

counts for days of week

hi,

i am very new to php. started learning 3 days ago. i have figured out how to list MS Access table output in table format in PHP. but i need to know how i can have some output like following, based on a table with detail data. Days of the week Monday through sunday are across the top. i want the counts for each day listed for each shift.


shift1
shift2
shift3


can someone give me example. like a small example that i can get running with? i want to know how i can list the counts across the page for each day of the week, for each shift.


thanks in advance,
geebee
Jan 8 '09 #1
3 1790
Dormilich
8,658 Expert Mod 8TB
that depends on your data and how you access them. I can't tell anything without it, so maybe a representative snippet will help understanding.

further, what do you want to count?

regards
Jan 8 '09 #2
i am just getting the counts of records in the table that have a value corresponding to the day of the week in the [DY] column.

i have the following:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $test = array('sunday count','monday count','tuesday count','wednesday count','thursday count','friday count', 'saturday count');
  3. $day=date('w'); //Numeric representation of the day of the week  0 (for Sunday) through 6 (for Saturday)
  4. $key=each($test);
  5. while ($key['key']!=$day)
  6.     $key=each($test);
  7. prev($test);
  8. prev($test);
  9. for ($i=0;$i<7;$i++)
  10. {
  11.     $count = (next($test)) ? current($test) : reset($test);
  12.     echo $count.'<br />';
  13. }
  14. ?>

this simply lists the days of the week. and the first day is automatically set to today. but what i want is for the days of the week to be listed across the top. and for the shifts 1 2 and 3 to be listed down the left side, and for recordcounts to be listed under each weekday name and for each shift.

thanks in advance,
geebee
Jan 8 '09 #3
Dormilich
8,658 Expert Mod 8TB
@geraldjr30
since the week days won't change that easily, code them as table head in html. then you can loop over each "shift" building a row.

sample: (does not necessarily fits your system but illustrating)
Expand|Select|Wrap|Line Numbers
  1. $row_html = '<tr><td>shift%d</td><td>%s</td> ... </tr>'; // 8 cells
  2. // for now assuming $shifts holds the count value for each day in the shift
  3. // $shifts[0]['sunday'] / $shifts[0]['monday'] / ...
  4. // $shifts[1]['sunday'] / $shifts[1]['monday'] / ...
  5. $count = 0;
  6. foreach ($shifts as $shift)
  7. {
  8.   // replaces the "%d" and "%s"
  9.   printf($row_html, ++$count, $shift['sunday'], $shift['monday'], ...); // fill with values
  10. }
regards
Jan 8 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: WertmanTheMad | last post by:
Ive been playing with this for a few days and thought I might thow it out for seggestions. I have Several Queries that need counts returned The Queries are Mutually Exclusive meaning whatever...
5
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular...
1
by: rock72 | last post by:
I am developing a application using this fields as required by the company. 1. Date Login 2. Time IN 3. Time OUT My question is how to produce the number of days with 1 entry of Date is...
2
by: MAF | last post by:
Is there a way through globalization to get the days of the week based on culture?
19
by: Ricardo Perez Lopez | last post by:
Hello everyone: I'm a PostgreSQL newbie, working now with dates, times, timestamps and intervals. I have three questions about the above: FIRST: --------
5
by: Simon Dean | last post by:
Probably being a little thick here, but when you subtract one date away from another, how do you convert the resultant value into a number of days... I guess I could easily / 60 / 60 / 24... but...
7
by: No bother | last post by:
I have a table which has, among other fields, a date field. I want to get a count of records where certain criteria are met for, say, three days in a row. For example: NumWidgets Date...
7
by: antheana | last post by:
Grrr I just lost the post so have to start again, I hope I don't miss anything! Hello!!! Ok, so I have a database (MS Access 2003), which has a Jobs table and has information about the client,...
2
by: tasmontique | last post by:
I am working on an access 2002 flight schedule database. I am new to access but have some basic understanding of sql and vb6 code. I have learned a lot from this website. Thanks much Hopefully...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.