Exoon Posted January 12, 2009 Share Posted January 12, 2009 Hello, I'm making a link exchange script and i was wondering what would be the best way to make it. Ive got the stats tracking for each day for hits in and hits out, every day them hits are placed into another field in the database which is to display the hits which happened yesterday. I also want to display the hits for a whole month for hits in and hits out and display the difference so i know how much traffic i owe certain sites. This is the part I'm stuck on really, do i need 60 fields in the database for each days in and out hits then find out the difference between the total. Im really confused and need some advice. Thanks Exoon Quote Link to comment https://forums.phpfreaks.com/topic/140511-link-exchange-script/ Share on other sites More sharing options...
ngreenwood6 Posted January 12, 2009 Share Posted January 12, 2009 No you only really need about 4 fields: id hits_in hits_out time In the time field you would put a timestamp. A timestamp looks like this 094345834. It is the number of seconds since a long time ago. You can then query the database against that to see the results you want. For example: $last_day = 60*60*24; //60 seconds time 60 minutes times 24 hours is a day $time = time(); //makes it the 094345834 $twenty_four_hours = $time - $last_day; Again this is just an example. Quote Link to comment https://forums.phpfreaks.com/topic/140511-link-exchange-script/#findComment-735273 Share on other sites More sharing options...
Exoon Posted January 12, 2009 Author Share Posted January 12, 2009 Thanks for the reply How would this work with monthly hits though? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/140511-link-exchange-script/#findComment-735289 Share on other sites More sharing options...
premiso Posted January 12, 2009 Share Posted January 12, 2009 Easy, you just use the timestamp to pull up the month you want. Quote Link to comment https://forums.phpfreaks.com/topic/140511-link-exchange-script/#findComment-735293 Share on other sites More sharing options...
ngreenwood6 Posted January 12, 2009 Share Posted January 12, 2009 Adding to what premiso said I will give you an example. You can convert a timestamp to a date using the date() function like this: $time = time(); $date = date("m/d/Y", $time); I would look into the timestamp and date functions a little farther if I was you. Quote Link to comment https://forums.phpfreaks.com/topic/140511-link-exchange-script/#findComment-735335 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.