之後獲得一個列值(如id)我可以從PHP中獲得一個值,就像我剛剛添加到數據庫的行中的新ID一樣,或者我應該使用SELECT來檢索它?mysql INSERT
<?php
$sql = "INSERT INTO my_table (column_1, column_2) VALUES ('hello', 'ciao')";
$res = mysql_query ($sql) or die (mysql_error());
$sql = "SELECT column_id FROM my_table WHERE column_1 = 'hello'";
$res = mysql_query ($sql) or die (mysql_error());
$row = mysql_fetch_assoc ($res);
$id = $row["column_id"];
print "my id is = $id";
?>