How to Generate Serial Number or Complaint Number in Series ??
Like:
A000000000 A000000001 A000000002 A000000003 A000000004 A000000005 A000000006 A000000007 A000000008 A000000009 A000000010 A000000011 A000000012 A000000013 A000000014 A000000015 and so on
Html:
<form method="post" action="serialnumber.php">
Name : <input type="text" name="name" value="" />
<input type="submit" value="Save" name="save" />
</form>
Php Code:
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('serialnumber_db',$con);
if(isset($_POST['save']))
{
$qr="select sn from serialnumber";
$result=mysql_query($qr);
if(mysql_num_rows($result)<=0)
{
$serialNo='A000000000';
}
else
while($data=mysql_fetch_array($result))
{
$cur_ser=$data['sn'];
if($cur_ser=='')
{
$serialNo='A000000000';
}
else
{
$serialNo=++$cur_ser;
}
}
$name=$_POST['name'];
$sql="INSERT INTO `serialnumber`(`name`, `sn`) VALUES ('$name' , '$serialNo')";
$res=mysql_query($sql);
if($res)
{
echo "Saved";
$query="select * from serialnumber";
$res=mysql_query($query);
if($res)
{
echo "<table><tr><th>S.no.</th><th>Name</th></tr>";
while($data=mysql_fetch_array($res))
{
echo "<tr><td>$data[sn]</td><td>$data[name]</td></tr>";
}
echo "</table>";
}
}
else
{
die (mysql_error());
}
}
?>
Database Table:
First create New Database with "serialnumber_db" Name
Second Create table as :
CREATE TABLE IF NOT EXISTS `serialnumber` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`sn` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
So it will result as :
Like:
A000000000 A000000001 A000000002 A000000003 A000000004 A000000005 A000000006 A000000007 A000000008 A000000009 A000000010 A000000011 A000000012 A000000013 A000000014 A000000015 and so on
Html:
<form method="post" action="serialnumber.php">
Name : <input type="text" name="name" value="" />
<input type="submit" value="Save" name="save" />
</form>
Php Code:
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('serialnumber_db',$con);
if(isset($_POST['save']))
{
$qr="select sn from serialnumber";
$result=mysql_query($qr);
if(mysql_num_rows($result)<=0)
{
$serialNo='A000000000';
}
else
while($data=mysql_fetch_array($result))
{
$cur_ser=$data['sn'];
if($cur_ser=='')
{
$serialNo='A000000000';
}
else
{
$serialNo=++$cur_ser;
}
}
$name=$_POST['name'];
$sql="INSERT INTO `serialnumber`(`name`, `sn`) VALUES ('$name' , '$serialNo')";
$res=mysql_query($sql);
if($res)
{
echo "Saved";
$query="select * from serialnumber";
$res=mysql_query($query);
if($res)
{
echo "<table><tr><th>S.no.</th><th>Name</th></tr>";
while($data=mysql_fetch_array($res))
{
echo "<tr><td>$data[sn]</td><td>$data[name]</td></tr>";
}
echo "</table>";
}
}
else
{
die (mysql_error());
}
}
?>
Database Table:
First create New Database with "serialnumber_db" Name
Second Create table as :
CREATE TABLE IF NOT EXISTS `serialnumber` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`sn` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
So it will result as :
S.no. | Name |
---|---|
A000000000 | ajay |
A000000001 | amar |
A000000002 | amit |
A000000003 | vikas |
A000000004 | madhuri |
A000000005 | mayak |
A000000006 | avinash |
A000000007 | durgesh |
A000000008 | charu |
A000000009 | aman |
A000000010 | vijay |
A000000011 | rohit |
A000000012 | ritesh |
A000000013 | raman |
A000000014 | prachi |
A000000015 | manish |
No comments:
Post a Comment