Jump to content

[SOLVED] unique Id in a for loop


sager29

Recommended Posts

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";
}

Link to comment
https://forums.phpfreaks.com/topic/86424-solved-unique-id-in-a-for-loop/
Share on other sites

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.