Jump to content

mysql id..?


ikkyino

Recommended Posts

Heylo, wondering if this would work..? i want an id so if i want to delete a row i can do it by id vs. names where i'll have duplicates...

$sql="INSERT INTO movies (Title, Rate, Length)VALUES('$_POST[title]','$_POST[rate]','$_POST[length]')";$sql2 = "INSERT INTO movies (Id)VALUES ('mysql_insert_id()')";

i'm sure there's a better way, but i don't know it :).. so help on how to do it would be great :)-Ikky

Link to comment
Share on other sites

Heylo, wondering if this would work..? i want an id so if i want to delete a row i can do it by id vs. names where i'll have duplicates...
$sql="INSERT INTO movies (Title, Rate, Length)VALUES('$_POST[title]','$_POST[rate]','$_POST[length]')";$sql2 = "INSERT INTO movies (Id)VALUES ('mysql_insert_id()')";

i'm sure there's a better way, but i don't know it :).. so help on how to do it would be great :)-Ikky

The way you're doing it, it will create two registers: one without an ID and one that only has an ID.If you want an ID for registers of the table you just need to add an ID field to it and give it the AUTO_INCREMENT feature.
Link to comment
Share on other sites

The id field can also benefit from being PRIMARY KEY (speeds up table processing).id INT(6) NOT NULL PRIMARY KEY AUTO_INCREMENT

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...