sager29 Posted January 17, 2008 Share Posted January 17, 2008 What I'm trying to do is get a new unique id each time it loops, but i get the same ID in each of my row in my table. some times it only loops once, other times it loops 12 times or more. Any suggestions would be appreciated. thanks $quantity = whichever number is selected $transaction=uniqid("YOUR_"); for ($i=1; $i<=$quantity; $i++) { $sql="INSERT INTO listings (listID, status) VALUES ('$transaction', 'active')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "success"; } Quote Link to comment https://forums.phpfreaks.com/topic/86424-solved-unique-id-in-a-for-loop/ Share on other sites More sharing options...
predator Posted January 17, 2008 Share Posted January 17, 2008 it would put the same one in because all ur enterin in the database is $transaction you can just make the id field increment automatically when you enter a new row into the database did you no that? Quote Link to comment https://forums.phpfreaks.com/topic/86424-solved-unique-id-in-a-for-loop/#findComment-441790 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.