Android & MySQL: Get mysql_insert_id() and retrieve it in Android Activity
<p>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</p>

<pre><code>if (isset($_POST['name']) &amp;&amp; isset($_POST['price']) &amp;&amp; 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')");
</code></pre>

<p>Where should I put <code>mysql_insert_id()</code> ?</p>

<p>Finally, how could I get that <code>mysql_insert_id()</code> in my android activity?</p>

<p>Thanks in advance</p>
