0

I have a query that looks for videos with a certain groupid and returns the result. In this result I need to find the position of a certain $vid_id:

  function getGroupVidPos($id,$vid_id)
  {
    global $db;
    $result = $db->query("SELECT * FROM videos WHERE `groupid`='$id' ORDER BY date DESC");
    $a = $db->fetch($result);
    return $a;
  }

Can I do this in the MySQL statement it self? Or better use array_search? Or any other ideas?

Michal
  • 3,262
  • 4
  • 30
  • 50
  • 2
    What exactly do you mean with `the position of`, do you need the record or its place in the result set? – jeroen Apr 02 '12 at 02:00
  • @jeroen - it's place in the result set - the query returns i.e. 10 rows, I need to find out what position the $vid_id is in those... – Michal Apr 02 '12 at 02:02
  • 1
    you can generate row numbers. take a look at this article; http://stackoverflow.com/questions/2520357/mysql-get-row-number-on-select – Selçuk Apr 02 '12 at 02:07
  • well, seems like a rather complicated way, isn't it? – Michal Apr 02 '12 at 02:13

0 Answers0