doucan2102
2013-04-19 22:23Android和MySQL:获取mysql_insert_id()并在Android Activity中检索它
Hi I have connected a MySQL in a server with and Android application using JSON. I have a table called products where the primary key is and id which is auto_increment. When I insert a new product I would like to get that Id in my android Activity but I don't know how to retrieve it in PHP nor Android. Here is some code: Create Product Script
if (isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])) {
$name = $_POST['name'];
$price = $_POST['price'];
$description = $_POST['description'];
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// mysql inserting a new row
$result = mysql_query("INSERT INTO products(name, price, description) VALUES('$name', '$price', '$description')");
Where should I put mysql_insert_id()
?
Finally, how could I get that mysql_insert_id()
in my android activity?
Thanks in advance
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 如何从MYSQL数据库中检索数据并在Android上点击Button进行验证
- android
- mysql
- php
- 1个回答
- 无法使用php + android从mysql中检索数据
- json
- android
- mysql
- php
- 2个回答
- Android和MySQL:获取mysql_insert_id()并在Android Activity中检索它
- android
- php
- 1个回答
- Postparameter报错误信息
- android
- mysql
- activity
- 1个回答