If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Create row numbers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-11-09, 20:18
oldnickj oldnickj is offline
Registered User
 
Join Date: Jan 2009
Posts: 103
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
Reply With Quote
  #2 (permalink)  
Old 08-12-09, 08:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-12-09, 11:15
oldnickj oldnickj is offline
Registered User
 
Join Date: Jan 2009
Posts: 103
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
Reply With Quote
  #4 (permalink)  
Old 08-12-09, 12:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
can't you just load the rows into javascript and "walk the DOM" assigning values that way?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 08-12-09, 13:25
oldnickj oldnickj is offline
Registered User
 
Join Date: Jan 2009
Posts: 103
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.
Reply With Quote
  #6 (permalink)  
Old 08-12-09, 13:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On