RON_ron Posted September 6, 2010 Share Posted September 6, 2010 How do I get the number as pairs? (i.e. 05, 20, 01, 70) $query = "SELECT statez, COUNT(statez)FROM distributors GROUP BY statez"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['COUNT(statez)'] ." Distributors in ". $row['statez']; echo "<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/ Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 You mean with the leading zero? That would depend how you're storing the number, what data type is the column? Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/#findComment-1107796 Share on other sites More sharing options...
RON_ron Posted September 6, 2010 Author Share Posted September 6, 2010 varchar Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/#findComment-1107798 Share on other sites More sharing options...
mraza Posted September 6, 2010 Share Posted September 6, 2010 i think if u do that with decimal it would work but as a simple fix i used this once $var = ($num<10) ? "0$num" : $num; Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/#findComment-1107799 Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 Just use str_pad. Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/#findComment-1107800 Share on other sites More sharing options...
RON_ron Posted September 6, 2010 Author Share Posted September 6, 2010 Thanks Mr.Adam. Quote Link to comment https://forums.phpfreaks.com/topic/212654-all-digits-to-be-as-pairs/#findComment-1107807 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.