Results 1 to 4 of 4

Thread: No of Row

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    No of Row

    If I have this table

    ID User
    1 A
    3 B
    6 C
    8 D


    How can I know the no of row that it's ID=6 ?

    the no of row that it's ID=6 here is 3

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    One way would be to cycle through all your rows and have a counter figure out which row you are actually on.

    PHP Code:
    // assuming you are connected to your database
    $query mysql_query("select id from table order by id");
    for (
    $i=0;$i<mysql_num_rows($query);$i++)
      if (
    mysql_result($query,$i,"id") == 6)
        break;

    echo 
    $i
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    I do not mean that

    ID is auto and it does not repeat at all

    I mean it's=3 becase this row in the third row

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    that is what that function will tell you. It will tell you that id 6 is on the 3rd row. Actually it will say 2 b/c it starts at zero.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width