I can get the ID just after INSERT by mysql_insert_id(); but I want to save an image in the form of ID-image_name.jpg and save it in a column named Image_Name. How can I save the image with forthcoming ID? Or it is better to save the image file after INSERT process?
Saving it after the INSERT process is the most straightforward way.
mysql_query("INSERT INTO....."); // etc. etc.
$id = mysql_insert_id();
mysql_query("UPDATE table SET image = '$image_name' WHERE id = '$id'");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With