Jump to content

[SOLVED] Concatenate


hamishrock

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.