1,105,384 Community Members

appending number to a value...help

Member Avatar
gopi17
Junior Poster
104 posts since Sep 2008
Reputation Points: 8 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

helloo....guys need a favour from you....okay this is the scenario
i have a attribute called document_no,
now i would like to append running numbers behind it to fill in a new attribute
eg:

document_no = 123222
serial_no = 12322201
12322202
12322203

now the number starts from 01 and go on up to 64(according to the pallet no.)

any idea how to do this...because not that i append...the '0' goes missing and its 1232221

thank you...

Member Avatar
jkon
Posting Pro in Training
444 posts since Jan 2009
Reputation Points: 110 [?]
Q&As Helped to Solve: 74 [?]
Skill Endorsements: 6 [?]
 
0
 
<?php
echo "wrong way<br/>";
for($i=0; $i<20; $i++)
{
  $a = "23".$i; 
  echo $a."<br/>";
}

echo "an easy solution<br/>";
for($i=0; $i<20; $i++)
{
  $a = (int)"23".($i<10 ? "0".$i : $i); 
  echo $a."<br/>";
}
?>
Question Answered as of 2 Years Ago by jkon
Member Avatar
gopi17
Junior Poster
104 posts since Sep 2008
Reputation Points: 8 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

heyy...thank you for your help...i solve the problem d...

for($i=1; $i<=$palletno; $i++)
{
    $serial_no = $document_no.($i<10 ? "0".$i : $i);

$sql1="INSERT INTO $tbl_name1(invoice_no,container_no,document_no,part_no,spart_no,serial_no,scan_status)VALUES('".$invoice_no1."','".$container_no."','".$document_no."','".$part_no."','".$spart_no."','".$serial_no."','unscanned')" or die(mysql_error());		
		$result=mysql_query($sql1)or die(mysql_error());
}
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: