gardan06 Posted October 13, 2006 Share Posted October 13, 2006 if you set your primary key as auto_incremented and you have a query "insert into table values('','{$var2}'...)", how can you save the newly saved primary key as a variable? Link to comment https://forums.phpfreaks.com/topic/23825-getting-an-auto_incremented-integer/ Share on other sites More sharing options...
extrovertive Posted October 13, 2006 Share Posted October 13, 2006 $id = mysql_insert_id Link to comment https://forums.phpfreaks.com/topic/23825-getting-an-auto_incremented-integer/#findComment-108203 Share on other sites More sharing options...
Toolmaster Posted March 15, 2008 Share Posted March 15, 2008 I know this thread is probably old, but I need help with Auto Increment.This is the table I have created with auto_increment:CREATE TABLE appointment(appointment_id MEDIUMINT NOT NULL AUTO_INCREMENT, Primary Key (appointment_id), student_id varchar(8), INDEX (student_id), FOREIGN KEY (student_id) REFERENCES student(student_id), lecturer_name varchar(50), INDEX (lecturer_name), FOREIGN KEY (lecturer_name) REFERENCES lecturer(lecturer_name), appointment_date DATE, appointment_time TIME) TYPE=INNODB;Is the auto increment value also set as a primary key through Primary Key (appointment_id) or does it overide the primary key and its rules? Link to comment https://forums.phpfreaks.com/topic/23825-getting-an-auto_incremented-integer/#findComment-492710 Share on other sites More sharing options...
Toolmaster Posted March 15, 2008 Share Posted March 15, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/23825-getting-an-auto_incremented-integer/#findComment-492856 Share on other sites More sharing options...
BlueSkyIS Posted March 15, 2008 Share Posted March 15, 2008 auto increment and primary key are compatible and often used together so you don't have to manually increment the primary key. Link to comment https://forums.phpfreaks.com/topic/23825-getting-an-auto_incremented-integer/#findComment-492895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.