Page 4 of 4
Posted: Thu Dec 14, 2006 11:58 am
by neel_basu
You Can Get The Org_id With This SQL Command
Code: Select all
select `org_id` from `table_name` where `person_id` = '$person_id' && `orgname` = '$orgname' && `web_url` = '$web_url' && `notes` = '$notes'
if And Only If
atleast one Of The person_id, orgname, web_url, notes is/are Unique Fields
Posted: Fri Dec 15, 2006 4:04 am
by mohson
My table is simple:
org_name varchar (100), web_url varchar (200), notes varchar (300),person_id int(11), org_id int(11) auto_increment
Are you saying replace:
Code: Select all
$sql = "INSERT INTO organisations (org_id,person_id, orgname, web_url, notes ) VALUES ('$org_id','$person_id','$orgname','$web_url', '$notes')";
With
Code: Select all
SELECT `org_id` FROM `table_name` WHERE `person_id` = '$person_id' && `orgname` = '$orgname' && `web_url` = '$web_url' && `notes` = '$notes'
That doesnt make sense my one is an insert statement your one is a select statement?
Please explain?
Posted: Fri Dec 15, 2006 9:51 am
by RobertGonzalez
He's saying after the insert select the last inserted record. But if the field you want to fetch from the last insert is an autoincrement field then
mysql_insert_id() will have already grabbed it.