2014-11-05 16 views
-1

當我添加新記錄時,我希望能夠返回其值id(主索引auto int)。有沒有辦法做到這一點?我如何獲得id的值及其創建的記錄的索引

我的代碼:

<? 

mysql_connect(localhost,"learning_bitcoin","oreo8157"); 
mysql_select_db("learning_bitcoins") or die("Unable to select database"); 
print("open a database"); 

$query = "INSERT INTO buy VALUES ('','','".$_GET['market'] ."','".$_GET['price'] ."','','".$_GET['shares'] . 
"','".$_GET['real'] ."','')"; 
$rs=mysql_query($query); 

if (!$rs) { 
    echo "Could not execute query: $query\n"; 
    trigger_error(mysql_error(), E_USER_ERROR); 
} else { 
    echo "Query: $query executed\n"; 
} 

?> 
+0

這很容易:-(查看關於PDO和/或mysqli - 並準備好陳述,現在更改密碼。 – Strawberry 2014-11-06 00:25:38

回答

相關問題