Jump to content

Recommended Posts

I have the idea of making a hourly statistic output for a business on its sales for a 24 hour cycle.

 

As there are 24 hours in day, would that mean I need 24 fields in a business table to do this?

For example I currently have done this:

 

--------

Business ID

Owner ID

Money

RecordID

01:00 Sales Total

02:00 Sales Total

03:00 Sales Total

(etc up to 24:00 Sales Total)

--------

 

 

Is this the most efficient way to do it? It seems an awful lot of duplicated fields.. don't know if there is perhaps a smarter way to approach this?

Link to comment
https://forums.phpfreaks.com/topic/108768-database-table-sales-chart/
Share on other sites

You could use one column (wages)

 

Say wages for hour one = 10

 

<?php

$h = 10
// insert into db
// db now contains 10

?>

 

then after another hour

 

<?php

$h = 20

$result = mysql_query("SELECT wages FROM table");
$row = mysql_fetch_array($result);

$data = $row['wages'] . ',' . $h;
// update db
// db now contains 10,20

?>

 

And then you could explode the results at the end of 24 hours into an array

 

<?php

$result = mysql_query("SELECT wages FROM table");
$row = mysql_fetch_array($result);

$wages = explode(',', $row['wages']);

// $wages[0] = 10
// $wages[1] = 20
// etc..

?>

 

Not sure if that's practical though, there's probably a better way I don't know about

 

P.S. Just read your post again, not sure where I got wages from, lol.

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.