# SQL help

**URL:** <https://forum.kirupa.com/t/sql-help/233193>\
**Category:** Uncategorized\
**Created:** [July 21, 2007, 12:10am UTC](https://forum.kirupa.com/t/sql-help/233193 "2007-07-21T00:10:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wo1olf](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@wo1olf](https://forum.kirupa.com/u/wo1olf)\
**Post date:** [July 21, 2007, 12:10am UTC](https://forum.kirupa.com/t/sql-help/233193/1 "2007-07-21T00:10:05Z")

</div>

I want to get the last index of my table, in order to remove the last row added.  
I have 2 functions  
addRow() wich adds a new row and removeRow() which remove row. I use mysql\_insert\_id() in the addRow function to return the last index. The thing is I’m trying to get it and the use it in the secon function but it doesn’t work.  
How can id do it  
here is my code

```php
function addRow()
(...) // add a new row
return mysql_insert_id ();

function removeRow($id)
(...)// remove the 

$index = addRow();

if (isset(...))
removeRow($index);

```

how can i do it ?
