Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:06:05+00:00 2026-06-09T23:06:05+00:00

If my data in collection mongo is something like this { _id : ObjectId(4fff9946af8c6149aed251ab),

  • 0

If my data in collection mongo is something like this

{ "_id" : ObjectId("4fff9946af8c6149aed251ab"), "subject_slug" : "math", "lesson_slug" : "mat01" }
{ "_id" : ObjectId("4fff9946af8c6149aed251ac"), "subject_slug" : "math", "lesson_slug" : "mat02" }
{ "_id" : ObjectId("4fff9946af8c6149aed251ad"), "subject_slug" : "math", "lesson_slug" : "mat03" }
{ "_id" : ObjectId("4fff9946af8c6149aed251ae"), "subject_slug" : "eng", "lesson_slug" : "eng01" }
{ "_id" : ObjectId("4fff9946af8c6149aed251af"), "subject_slug" : "eng", "lesson_slug" : "eng02" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b0"), "subject_slug" : "eng", "lesson_slug" : "eng03" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b1"), "subject_slug" : "phy", "lesson_slug" : "phy01" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b2"), "subject_slug" : "phy", "lesson_slug" : "phy02" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b3"), "subject_slug" : "phy", "lesson_slug" : "phy03" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b4"), "subject_slug" : "chem", "lesson_slug" : "che01" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b5"), "subject_slug" : "chem", "lesson_slug" : "che02" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b6"), "subject_slug" : "chem", "lesson_slug" : "che03" }
{ "_id" : ObjectId("4fff9946af8c6149aed251b7"), "subject_slug" : "chem", "lesson_slug" : "che04" }

and If I want data in row 6 without loop data. Is there short code in php to get data in that row ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:06:07+00:00Added an answer on June 9, 2026 at 11:06 pm

    In order to find the sixth record, you need to make use of some MongoCursor methods:

    • sort() so there is a specific order (eg. by _id)
    • skip() to skip a number of records (skip 5 to find the 6th)
    • limit() to limit to one result

    Code example:

    <?php
        $mongo = new Mongo();
        $collection = $mongo->mydb->subject;
    
        $query = array();
        $sort  = array('_id' => 1);
    
        // Find the 6th record
        $doc = $collection->find($query)->sort($sort)->skip(5)->limit(1)->getNext();
    
        print_r($doc);
    ?>
    

    Sample output:

    Array
    (
        [_id] => MongoId Object
            (
                [$id] => 4fff9946af8c6149aed251b0
            )
    
        [subject_slug] => eng
        [lesson_slug] => eng03
    )
    

    Note that the performance of skip() may be an issue if you need to skip over a large number of documents. A more performant option, if possible, would be to use range queries with a limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a mongo collection like this: { A2_AboutMe: , A2_Attributes: |av|nv|, A2_Birthday: ,
I'm trying to query a collection in mongo that's structured like this... { type:apple
I have a collection in mongo in which I am inserting data from Perl
I have a necessity to remove all data from mongo collection. Droping of collection
I have a small data collection app which has a single button to start
We have a data collection system that collects measurements from environmental sensors that measure
We have a large internal data collection website. I don't have time to create
I am trying to group a data collection and send it to the View
I just realized that I need to synchronize a significant amount of data collection
I have a MongoDB collection with data that was not saved through my Derby

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.