PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Graphisme & Infographie > macromedia.dreamweaver > Retrieving the row number of a specific record from theresults of a MySQL query
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Retrieving the row number of a specific record from theresults of a MySQL query

Réponse
 
LinkBack Outils de la discussion
Vieux 01/07/2008, 21h33   #1
AngryCloud
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Retrieving the row number of a specific record from theresults of a MySQL query

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
  Réponse avec citation
Vieux 01/07/2008, 21h44   #2
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Retrieving the row number of a specific record from the results of a MySQL query

..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
  Réponse avec citation
Vieux 01/07/2008, 22h08   #3
AngryCloud
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Retrieving the row number of a specific record fromthe results of a MySQL query

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?

  Réponse avec citation
Vieux 01/07/2008, 22h17   #4
Murray *ACE*
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Retrieving the row number of a specific record from the results of a MySQL query

<?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?
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h11.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08310 seconds with 12 queries