Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    124

    Unanswered: Create row numbers

    I need tyo number the rows resulting from a SELECT statement beginning with 0 (zero). Regardless of the record id I want the results to have an artificial field called num and it would be incremental starting with 0.

    I could dothis in PHP but I need the results in javascript within the head tag, ( it this makes sense!)

    Hum... I need teh array tobe numbered 01234 despite the fact that the db records don't begin with 0.

    Nick

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by oldnickj
    I could dothis in PHP but I need the results in javascript within the head tag, ( it this makes sense!)
    no, it doesn't make sense

    why can't you do it in php?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2009
    Posts
    124

    Life makes no sense but SQL should..

    (Hi Rudy)

    I need to populate a scrip on opening before the array is created. It's an image slide show script which normally uses any number of hard coded. the files have to be numbered 01234 etc. but the id's in the database will change with the changes in files as time goes on. I'm thinking a temporary table id which starts with zero. Then in the script use and array of whoever many images the client wants to upload.

    Nick

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    can't you just load the rows into javascript and "walk the DOM" assigning values that way?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2009
    Posts
    124
    the row don't have row numbers starting with zero! What I need is a way to add row numbers starting with zero for the rows returned by the query.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by oldnickj
    the row don't have row numbers starting with zero! What I need is a way to add row numbers starting with zero for the rows returned by the query.
    you can do that with the DOM (although i'm not the one to show you how)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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