Getting MySQL User Variable in Sequence, While Using ORDER BY RAND()
You need to get your random row-set first and then number the rows.

SQL Fiddle

MySQL 5.5.32 Schema Setup:

CREATE TABLE tbl
    (`ID` int)
;

INSERT INTO tbl
    (`ID`)
VALUES
    (1),
    (2),
    (3),
    (4),
    (5),
    (6),
    (7),
    (8),
    (9),
   (10),
   (11),
   (12),
   (13),
   (14),
   (15),
   (16),
   (17),
   (18),
   (19),
   (20)
;


Use LIMIT and ORDER BY RAND() together to get your random row-set:    

Query 1:

SELECT * 
  FROM tbl 
 ORDER BY RAND()
 LIMIT 5;


Results:

| ID |
|----|
| 18 |
| 10 |
| 15 |
| 16 |
|  2 |


Wrap that into an outer query to apply the row numbering:

Query 2:

SELECT ID,@counter:=@counter+1 as counter 
FROM (
  SELECT * 
    FROM tbl 
   ORDER BY RAND()
   LIMIT 5
  )t 
INNER JOIN (SELECT @counter:=-1) b;


Results:

| ID | COUNTER |
|----|---------|
| 19 |       0 |
| 10 |       1 |
|  1 |       2 |
|  7 |       3 |
| 17 |       4 |


Running the same query again to show its really random:

Query 3:

SELECT ID,@counter:=@counter+1 as counter 
FROM (
  SELECT * 
    FROM tbl 
   ORDER BY RAND()
   LIMIT 5
  )t 
INNER JOIN (SELECT @counter:=-1) b;


Results:

| ID | COUNTER |
|----|---------|
|  4 |       0 |
|  8 |       1 |
| 18 |       2 |
| 14 |       3 |
| 16 |       4 |