hamishrock Posted November 26, 2006 Share Posted November 26, 2006 Just learning PHP.How can I make a number have leading zeros.My db is a varchar(3) and is assigned a number to it, but using the code below won't give me "015"[color=blue]<?php $topn = 1;if (mysql_num_rows($result) > 0) { while(list($memmax)=mysql_fetch_array($result)){ $topn =$memmax +1; }if ($topn < 10) { $topns = "00" + $topn; }else if ($topn < 100) { $topns = "0" + $topn; }$sql = "Insert members (membership) Values '$topns'";//echo "$sql";//$result = mysql_query($sql);}echo $topn;?>[/color] Link to comment https://forums.phpfreaks.com/topic/28500-solved-concatenate/ Share on other sites More sharing options...
alpine Posted November 26, 2006 Share Posted November 26, 2006 It would be similar solutions as in this thread:http://www.phpfreaks.com/forums/index.php/topic,112541.msg459432.html#msg459432 Link to comment https://forums.phpfreaks.com/topic/28500-solved-concatenate/#findComment-130426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.