Is there a way to know the index (auto-increasing) of the last inserted row into a table in MySQL? What I'm trying to do: $sql = 'insert into mytable set product="'.$i.'", price="'.$j.'"'; $DB->query($sql); echo 'You have added '. $i .' at a price of '. $j .' and the id '. ???? .' into your table. PHP: Counting the rows won't work for me.