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

  • Home
  • SEARCH
  • 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 7672833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:22:33+00:00 2026-05-31T16:22:33+00:00

This is my php script for fetching data from a db. <?php mysql_connect(host,user,pass); mysql_select_db(db);

  • 0

This is my php script for fetching data from a db.

<?php

    mysql_connect("host","user","pass");

    mysql_select_db("db");

  $q=mysql_query("SELECT * FROM examples ")or die(mysql_error());

          $output[]=mysql_fetch_array($q,11);;

       print(json_encode($output));

mysql_close();?>

I have renamed the host and so on for obvious reasons. Isn’t this code supposed to get me all the rows from the examples table? It justs brings me the first row… Why that?

  • 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-05-31T16:22:35+00:00Added an answer on May 31, 2026 at 4:22 pm

    Did you read the docs? 🙂

    Use the following code to get all rows:

    $output = array();
    while($row = mysql_fetch_array($q)) {
        $output[] = $row;
    }
    

    You might want to use mysql_fetch_assoc() or mysql_fetch_object() though so you don’t have the (rather useless) numeric indexes in the resultset.

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

Sidebar

Related Questions

In this script, I'm fetching a load of data from a MySQL aray, and
I have this PHP script which i'm grabbing images from a directory and displaying
So I call this PHP script from the command line: /usr/bin/php /var/www/bims/index.php projects/output and
This PHP script prints all the data minus the XML to the browser (I'm
I am using php 5.2 and I am fetching data from url using file_get_contents
I have created this php script, to create an xml-file from my database: <?php
I'm running this php script at my database verbatim from a tutorial, yet I'm
I am fetching value using jQuery .get() like this $.get('clientarea.php', function(data) { var Val
I want to run this PHP script http://db2express/imacs/radek/3.1/rationalTest.php?mode=create from Sinatra. Sinatra runs on a
i'm builing this php script which displays a given folder 's children folders and

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.