you can use mysql_insert_id () function ,so just use:
$get_id=mysql_insert_id($sql);
then echo them.
echo"$get_id";
or you can use mysql internal function last_insert_id()
hope this helps.
----- Original Message -----
From: "Jefferis Peterson" <jefferis@p...>
To: "professional php" <pro_php@p...>
Sent: Friday, May 25, 2001 9:51 PM
Subject: [pro_php] fetching the current user id
> How do you fetch the field userid [autoincrement and dynamically
> assigned] from the current connection where $con = the current
> connection. This function isn't working:
>
>
> > $sql="insert into users (companyname, contactname, email, baddress1,
> >baddress2, bcity,
> >bstate, bzip, saddress1, saddress2, scity, sstate, szip, tel, fax,
> >active, bcountry, scountry,
> >needsvalidation) values ('$companyname', '$contactname', '$email',
> >'$baddress1', '$baddress2', '$bcity', '$bstate', '$bzip', '$saddress1',
> >'$saddress2', '$scity', '$sstate', '$szip', '$tel', '$fax',1,
> >'$bcountry', '$scountry',1)";
> >
> > mysql_query($sql,$con);
> > $get_id=mysql_query("select userid from users where
> >contactname='$contactname' and email='$email' ");
> > while ($row = mysql_fetch_array($get_id) )
> > { $id="$row[$userid]"; }
> > echo"i-$userid<br>";
>
>
>
> --
> Jefferis Kent Peterson
> www.PetersonSales.net
> Flash, Web Design and Marketing
> ICQ 19112253
>
>
>
>
>
>