1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MySQL Query Question (I guess it's something easy)

Discussion in 'PHP' started by Shadow, Mar 16, 2006.

  1. #1
    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.

    :eek:
     
    Shadow, Mar 16, 2006 IP
  2. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In php:
    mysql_insert_id()
     
    Dejavu, Mar 16, 2006 IP
    Shadow and sarahk like this.
  3. Shadow

    Shadow Peon

    Messages:
    191
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly, Thanks a lot :D
     
    Shadow, Mar 16, 2006 IP