This topic is locked
[SOLVED]

 How to update a field in the same row after record is ad

7/12/2011 7:28:35 AM
PHPRunner General questions
author

Probable a simple solution but I can't figure out how to set this up.
I have a table with two ID fields. (id and pid)
pid - is the primary key - auto increment.
id - really not sure why it is there? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17351&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
What I need is to have two auto increments in the table but I know that is not allowed.
So how can get the ID field to set to the value of the PID field after the record has been added?
Thanks for any help!!

C
cgphp 7/12/2011


global $conn;

$strSQL = "UPDATE patient_data SET id = ".$keys['pid']." WHERE pid=".$keys['pid'];

db_exec($strSQL,$conn);


This code is also valid for the "After record updated" event.

500496 7/12/2011




global $conn;

$strSQL = "UPDATE patient_data SET id = ".$keys['pid']." WHERE pid=".$keys['pid'];

db_exec($strSQL,$conn);


This code is also valid for the "After record updated" event.


Thank you!! Works great!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59412&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />