Click to See Complete Forum and Search --> : No of Row
prokhaled
Aug 2nd, 2002, 12:20 PM
If I have this table
ID User
1 A
3 B
6 C
8 D
How can I know the no of row that it's ID=6 ?
the no of row that it's ID=6 here is 3
cpradio
Aug 2nd, 2002, 01:13 PM
One way would be to cycle through all your rows and have a counter figure out which row you are actually on.
// assuming you are connected to your database
$query = mysql_query("select id from table order by id");
for ($i=0;$i<mysql_num_rows($query);$i++)
if (mysql_result($query,$i,"id") == 6)
break;
echo $i;
prokhaled
Aug 2nd, 2002, 01:25 PM
ID is auto and it does not repeat at all
I mean it's=3 becase this row in the third row
cpradio
Aug 2nd, 2002, 01:33 PM
that is what that function will tell you. It will tell you that id 6 is on the 3rd row. Actually it will say 2 b/c it starts at zero.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.