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 8474853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:44:10+00:00 2026-06-10T17:44:10+00:00

Alright, so I have a php that responds to a GET HTTP request; this

  • 0

Alright, so I have a php that responds to a GET HTTP request; this php script calls the database, and retrieves a set of rows.

$results = $db->pdoquery("SELECT * FROM posts JOIN users ON posts.user_id=users.id ORDER BY posts.cre DESC LIMIT 4");
    $json = json_encode($results);
    echo $json;

Now when I use backbonejs ‘.fetch’ command, it only returns 1 the first record, as opposed to the four.

If I change the php script I get all four, but I have to lose my JOIN

$results = $db->pdoquery("SELECT * FROM posts ORDER BY posts.cre DESC LIMIT 4");
    $json = json_encode($results);
    echo $json;

Can anyone explain what I’m doing wrong?

UPDATE :
The JSON that the php page prints

[{"id":"7","post_name":"title","pretty_url":"link1","preface":"a preface 7","body_text":"a body","feat":"0","img":"\/img\/logo.png","cre":"2012-07-22","modi":"2012-07-18","user_id":"2"},{"id":"6","post_name":"title","pretty_url":"link","preface":"a preface 6","body_text":"a body1","feat":"0","img":"\/img\/logo.png","cre":"2012-07-21","modi":"2012-07-18","user_id":"2"},{"id":"5","post_name":"TestTitle 1","pretty_url":"testlink4","preface":"a preface 5","body_text":"a body 2","feat":"0","img":"\/img\/logo.png","cre":"2012-07-20","modi":"2012-07-16","user_id":"2"},{"id":"4","post_name":"TestTitle 1","pretty_url":"testlink3","preface":"a preface 4","body_text":"a body 3","feat":"0","img":"\/img\/logo.png","cre":"2012-07-19","modi":"2012-07-16","user_id":"2"}]
  • 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-10T17:44:11+00:00Added an answer on June 10, 2026 at 5:44 pm

    I found the problem.

    Posts and Users has columns with identical names, mainly ‘id’, and since these four post records has the same user_id, the ‘id’ column was then set the same value.

    Backbone must have something built in that skips over what it considers to be identical records or something of the sort. Simply describing what I needed in more detail fixed the issue.

    Regardless the code that fixed it is below

            $results = $db->pdoquery("SELECT 
            posts.post_name, posts.pretty_url, posts.preface, posts.img, posts.cre, posts.modi, users.username
            FROM posts 
                JOIN users 
                    ON posts.user_id=users.id 
                    ORDER BY posts.cre 
                    DESC LIMIT 4");
        $json = json_encode($results);
        echo $json;
    

    Thanks to everyone that helped though.

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

Sidebar

Related Questions

Alright say that I have on a page, say form.php. On this form say
Alright so I have a php script which gets results from a DB, and
i keep getting this error for an array of errors that i have set
So, I have some PHP code that looks a bit like this: <body> The
Alright, currently I have my SWF hitting a php file that will go and
Alright so I'm trying to get captcha to work here and I have this
Alright i have a for loop in php and it generates a group of
Alright so I have no idea how to even begin doing this But basically
Alright so I have been trying to get all of my separate classes (At
Alright so I have a task, that I have to let the client try

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.