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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:16:13+00:00 2026-06-14T11:16:13+00:00

source code: $display = 1004; $result1 = mysql_query(SELECT id, username FROM users where parentid=$diplay);

  • 0

source code:

$display = 1004;
$result1 = mysql_query("SELECT id, username FROM users where parentid=$diplay");
$resrow = mysql_fetch_row($result1); 
$g = $resrow[0]; 
$g1 = $resrow[1]; 
$g2 = $resrow[3]; -error not display
$g3 = $resrow[4];
$g4 = $resrow[5];


echo "ID: $g";
echo "ID: $g2";
echo "ID: $g3";
echo "ID: $g4";

i have to show 1005, 1007, 1008 but i can retrieve $g value only:

ans: 1004 daniel

how i can show other values 1007,1008

Table

id           ----name  -----    parentid
-----------------------------------
1004            daniel         1003
1005            peter          1004
1007            michael        1004
1008            sam            1004

ans:

        $g
        1004
     /        \
    g2         g3   
   1005       1007
  • 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-14T11:16:14+00:00Added an answer on June 14, 2026 at 11:16 am

    You are confusing rows with columns. On this database:

    users
    id    | name    |  parentid
    ------+---------+----------
    1004  | daniel  |  1003
    1005  | peter   |  1004
    1007  | michael |  1004
    1008  | sam     |  1004
    

    The query SELECT id, name FROM users where parentid=1004 will return rows 1005, 1007, and 1008.

    mysql_fetch_row() only fetches one row at a time.
    That’s across (the id and name), not down (several ids).

    To get a list of all of the ID values that match, you need to loop through all the rows:

    $parentid = 1004;
    $result = mysql_query( "SELECT `id` FROM `users` WHERE `parentid`=$parentid" );
    while( $row = mysql_fetch_row( $result ) ){ $IDs[] = $row[0]; }
    // $IDs is now an array holding each id from the resultset.
    // It will look something like:
    /*
    array(3) {
     [0]=>
        int(1005)
     [1]=>
        int(1007)
     [2]=>
        int(1008)
    }
    */
    

    As mentioned above, don’t use ext/mysql for new work. I’m using it here only because that’s how you asked your original question. You need to update your code and use ext/mysqli or PDO instead.

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

Sidebar

Related Questions

I am trying to display Django source code from a Django template. However, I
Hey fellas, so I am able to display annotations (2) from the source code
I've a source code(test.cpp) that supposed to display three images(color, grayscale and canny) copied
I'm trying to display HTML source code in my NSDocument based application. However, it
I'm trying to download a website source code and display it in a textbox
i'm looking for ways to display and edit source code (ala google docs) in
Is there some clever content-type setting that makes Firefox display highlighted HTML source code
I want to pull the entire HTML source code file from a website in
This following is from the django source code ( Django-1.41/django/utils/encoding.py ); try: s =
HTML view source code is: <IMG style=DISPLAY: inline src=https://admit.belgacom.be/WCE/ESW/img/load.gif /> but When i login

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.