samoht Posted May 23, 2011 Share Posted May 23, 2011 Hello, I am wondering how to create a counter that has 5 digits and counts the results from a db field (not just the returned results but the numeric SUM of the values in the field) for display. i.e. if the sum of the field = 347 the counter would read 00347 I have created images for the numbers 0-9 and named them 0.png, 1.png, 2.png etc Also, I may have to sum a value that is stored in the db as serialized data (part of an array). If so how can I do that?? Link to comment https://forums.phpfreaks.com/topic/237248-custom-counter/ Share on other sites More sharing options...
AbraCadaver Posted May 23, 2011 Share Posted May 23, 2011 1. printf() or str_pad() should work. 2. You can't. You would need to get all records that match your criteria, unserialize and sum. That's one of the problems with serializing data in the db. Link to comment https://forums.phpfreaks.com/topic/237248-custom-counter/#findComment-1219194 Share on other sites More sharing options...
samoht Posted May 24, 2011 Author Share Posted May 24, 2011 Thanks AbraCadaver, I'll give those a try! Link to comment https://forums.phpfreaks.com/topic/237248-custom-counter/#findComment-1219355 Share on other sites More sharing options...
samoht Posted May 25, 2011 Author Share Posted May 25, 2011 OK, I guess I could use some help with printf() I get the concept but not sure how I figure out how many 0.png's I need to insert before the returned number value from the database? Also I saw another webpage using a similar counter idea but there numbers came from a single image that had the numbers 0-9 on it. Do they use sprites to make the number they need?? Link to comment https://forums.phpfreaks.com/topic/237248-custom-counter/#findComment-1219864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.