|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I want to create a MySQL query that will return a list of records, and then retrieve the row number of a record with a specific ID. How can I do this?
*server-side script: PHP |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
..oO(AngryCloud)
>I want to create a MySQL query that will return a list of records, and >then retrieve the row number of a record with a specific ID. How can I >do this? Records in a DB don't have row numbers, unless you explicitly store one. They are fetched and returned in whatever order you want them to be by using an ORDER BY clause. Of course you can use some counter variable in your script when you loop through the records. Micha |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
I will use this scenario for an example:
I want to know how far down the list I will find the ID, '57'. So I manually look at the list of results and see it is the 25th record down on the list. How do I get my PHP script to get this number (25) automatically? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
<?php
$i = 0; do { $i++; } while (mysql_fetch_assoc($rsWhatever) && $row_rsWhatever['ID'] !=57); echo "TADA -" . $i; ?> (assuming that ID is numeric, and that the test value actually exists in the database) -- Murray --- ICQ 71997575 Adobe Community Expert (If you *MUST* email me, don't LAUGH when you do so!) ================== http://www.projectseven.com/go - DW FAQs, Tutorials & Resources http://www.dwfaq.com - DW FAQs, Tutorials & Resources ================== "AngryCloud" <webforumsuser@macromedia.com> wrote in message news:g4e6ck$hrb$1@forums.macromedia.com... >I will use this scenario for an example: > > I want to know how far down the list I will find the ID, '57'. > > So I manually look at the list of results and see it is the 25th record > down > on the list. > > How do I get my PHP script to get this number (25) automatically? > |
|
![]() |
| Outils de la discussion | |
|
|