We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,285 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

appending number to a value...help

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

2
Contributors
2
Replies
22 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
gopi17
Junior Poster
105 posts since Sep 2008
Reputation Points: 18
Solved Threads: 3
Skill Endorsements: 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/>";
}
?>
jkon
Posting Whiz
383 posts since Jan 2009
Reputation Points: 124
Solved Threads: 63
Skill Endorsements: 4
Question Answered as of 1 Year Ago by jkon

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());
}
gopi17
Junior Poster
105 posts since Sep 2008
Reputation Points: 18
Solved Threads: 3
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0856 seconds using 2.72MB