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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:40:48+00:00 2026-06-05T08:40:48+00:00

I need to echo the 4th rows 3rd column from a mysql Database $query

  • 0

I need to echo the 4th rows 3rd column from a mysql Database

    $query = 'SELECT * FROM picture LIMIT 10';
    $result = mysql_query($query);
    $row = mysql_fetch_array($result,MYSQL_NUM );
  • Question 1 > What does the $result contain ? The table form as seen in MYSQL ?

  • Question 2 > What does the $row contain ? Just the 1st row ?

  • Question 3 > How can i move to the 4th row ? echo $row[4] doesn’t
    work!! ?

  • Question 4 > How can i move to the 4th row column 3 ?

    echo $row[4][3] doesn’t work!! ?

  • Question 5 – If i have to send 2 rows to back to the client side (
    suppose that ajax requested it from php )

would it be php

 $query = 'SELECT * FROM picture LIMIT 5';
$result = mysql_query($query);
$rec = mysql_fetch_array($result,MYSQL_NUM );

print_r (json_encode($result[0]));

And on html side

$.ajax({
      url: "viewnew.php",
      data: {
         current_image: imId,
         direction    : dir
      },
      success: function(ret){
          console.log(ret);
          var arr = eval(ret);
          alert("first: " + arr[0] + ", second: " + arr[1]);
  • 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-05T08:40:49+00:00Added an answer on June 5, 2026 at 8:40 am

    Your answer is echo mysql_result($result, 3, 3). You can also use echo mysql_result($result, 3, 'rowname'). Note that since it is zero-indexed, the fourth row is #3, as the first row is #0.

    $result contains a MySQL Query Result Object, you need to use the builtin functions to access it.

    $row does indeed just contain an array of the first row only. The internal pointer is increased, so if you ran the $row line of code twice, $row would now have the second row. Once you run out of rows, that line of code will evaluate to false (that’s useful below).

    php.net offers this piece of code:

    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        printf("ID: %s  Name: %s", $row[0], $row[1]);  
    }
    

    Since the while statement will evaluate to false when it runs out of rows, you get all the rows. Since you’re making the query, you should know how to handle the relevant data in each row.

    In regards to the AJAX, on server side, you need to assign the rows to array variables (as above) and then output the ones you want. Since you know how you will be outputting them, it is up to you how to handle them on client side.

    htmlspecialchars() or htmlentities() will make the data safe for output.

    A sample method would be as follows:

    $query = mysql_query(...);
    $rows = array();
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        $rows[] = $row; //append row to rows array
    }
    //Then output the relevant rows
    

    php.net has an extensive documentation of how to use the MySQL functions in PHP.

    Also, don’t forget security! mysql_real_escape_string() is almost always necessary when using user input to make a query.

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

Sidebar

Related Questions

I need to echo all items in my column that have the value of
I need to echo a value inside a WordPress Query. Here is my query
I need to recursivly echo comments and their respective children from a Jelly collection
I need to echo and order data from several different SQL tables. I cannot
I need to echo the MySQL version in a PHP script (it's a server
I need to echo entire content of included file. I have tried the below:
Simply I need to write echo t${count} = $t${count} To a text file, including
I need following sample bash script to behave as follows: echo -e Enter name:
I need to know if there's a way in PHP to echo a string
I want to issue the echo command inside a c++ file. All i need

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.