Jump to content

getting last auto incremented id and setting it as a variable ???


andrew_biggart

Recommended Posts

after adding a product i would like to get the last added item id and then set it as a variable!

 

im usuing the following code if anyone can help! Thanks

 

	<?


include("config.php");

if ($_POST['submit2'])
{
$prousid = ($_POST['prousid']);
$protit=($_POST['protit']);			
$prouspri=($_POST['propri']);
$proudes=($_POST['prodes']);
$day=($_POST['day']);
$month=($_POST['month']);
$year=($_POST['year']);
$hour=($_POST['hour']);
$min=($_POST['min']);
$catid=($_POST['catid']);




// Where you want the files to upload to
$uploaddir = "images"; // Where you want the files to upload to	

// Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);

//insert item and image into the database
$inssql = "INSERT INTO $tbl_name (user_id, category_id, item_image, item_name, item_starting_price, item_description, end_year, end_month, end_day, end_hour, end_min ) VALUES(  '$prousid', '$catid','" . $_FILES['file']['name']. "', '$protit', '$prouspri', '$proudes', '$year', '$month', '$day', '$hour', '$minute')";
mysql_query($inssql);
$item_id=mysql_insert_id() ;

echo "<br/>";
echo "<br/>";
echo "Success, Your product has now been added to urbanwear's databases and is now able to be bidded on.";			
echo "<br/>";
echo "<a href='item_details.php?id="$item_id"'>" Click hear to view your item "</a>";
echo "<br/>";
echo "Thankyou for using www.urbanwear.co.uk number 1 for buying and selling urban clothing... ";
echo "<br/>";
}	
else 
{
echo "OPSY !! ..  There was a problem with something, please go back and make sure everything has been entered correctly";
}

}
mysql_close();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.