Auto Number in PHP
<?php
mysql_connect("localhost","root","");
mysql_select_db("dabase_name");
$query=mysql_query("select uid from profile order by uid desc");
$row=mysql_fetch_array($q);
if(mysql_num_rows($q)>0)
{
$myid=$row['uid'];
$mynew=$myid+1;
}
$uname="user1";
$query="insert into profile (uid, uname) values ($mynew,'$uname')";
mysql_query($query);
echo "1 Record Added";
?>
mysql_connect("localhost","root","");
mysql_select_db("dabase_name");
$query=mysql_query("select uid from profile order by uid desc");
$row=mysql_fetch_array($q);
if(mysql_num_rows($q)>0)
{
$myid=$row['uid'];
$mynew=$myid+1;
}
$uname="user1";
$query="insert into profile (uid, uname) values ($mynew,'$uname')";
mysql_query($query);
echo "1 Record Added";
?>
Comments
Post a Comment