Simple number incrementation?

Discussion in 'PHP' started by le007, Jan 29, 2009.

  1. #1
    *Novice PHP'er*
    Can anyone show me some code to do the following please?

    Textbox that sends data to db (i can sort of do that)

    The textbox will allow people enter their email for a newsletter and as they click submit a number gets incremented, such as:

    We now have 101 newsletter subscribers.

    Thanks,
    Le007
     
    le007, Jan 29, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Or...

    SELECT COUNT(id) FROM `table`

    - Dan.
     
    Danltn, Jan 29, 2009 IP
  3. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Ok thanks dude :D
     
    le007, Jan 29, 2009 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    You can auto increment the primary key of that table, which is a good way to index it and uniquely indentify it.
     
    Kaizoku, Jan 30, 2009 IP
  5. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    And then how do I print it on screen please?
     
    le007, Jan 30, 2009 IP
  6. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    Anyone know how to print out the incremented ID? I just wanna store some emails in my database - thanks :D
     
    le007, Jan 30, 2009 IP
  7. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #7
    // connect to database
    $row = mysql_fetch_row(mysql_query("SELECT id FROM table"));
    echo $row[0];
     
    Kaizoku, Jan 30, 2009 IP
  8. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #8
    Thanks Kaizoku
     
    le007, Feb 2, 2009 IP