SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    select a row by its order in db, not by its id

    i have generated a random number and need to select a row from db that is that random position. because row id's can get out of order, i don't want to do it by selecting a row with specific id.

    i want to count from top and select teh row that's at that number position.

    how would i do that?
    Goals are dreams with deadlines
    -------------------------------------
    Nimlok Trade Show Displays Booths and Exhibits

  2. #2
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can grab all of the IDs out and put them in an array and then get the ID in the array[$i] and there is the one you want. as long as you don't do an order by in the query they should come out in the order they are in the db. (although I have never tested this...assumption here)
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Gent, Belgium, Europe, World, Univers
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in that case, if they come out the order you entered them, you can just use limit to get 1 record starting from $i

  4. #4
    SitePoint Addict
    Join Date
    Mar 2001
    Location
    the windy city
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    kajakske,
    that did it!
    Goals are dreams with deadlines
    -------------------------------------
    Nimlok Trade Show Displays Booths and Exhibits


Bookmarks

Posting Permissions

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