Im trying to figure out a way to access a row I 'just created' via the primary key.

As it being a primary key it is auto incremented.

I am using php/mysql to create the row then I require to access that same row (via the primary key) to be able to do the required adjustments.

So any ideas?

Thanks, Regards X

Recommended Answers

All 2 Replies

The unique id will work, or you could use the mysql_insert_id function to get the primary key of your last insert.

say you have a query you wrote:

$sql = "INSERT INTO ..."
$result = mysql_query($sql);

$keyid = mysql_insert_id($result);

Then keyid will have the primary key value, and you can use that to perform additional operations using the same primary key. Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.