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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:08:59+00:00 2026-05-17T15:08:59+00:00

I have a Mysql Recordset that I have put into an associative array so

  • 0

I have a Mysql Recordset that I have put into an associative array so that I can reuse it over and over.

I used this function to put the values into the array:

while(($Comments[] = mysql_fetch_assoc($rsComments)) || array_pop($Comments));

Here is what the print_r($Comments) displays

Array ( [0] => Array ( [CommentID] => 10 [Comment] => Ouch [CommentAuthor] => Randy Krohn [CommentDate] => 2010-10-06 17:19:49 [ID] => 1231 [CategoryID] => 42 ) [1] => Array ( [CommentID] => 12 [Comment] => This is the Dirty Duck [CommentAuthor] => John Lemoine [CommentDate] => 2010-10-06 17:22:43 [ID] => 1411 [CategoryID] => 42 ) [2] => Array ( [CommentID] => 13 [Comment] => Talk about deja vu! [CommentAuthor] => dber [CommentDate] => 2010-10-06 17:24:48 [ID] => 1473 [CategoryID] => 42 ) )

I am looping through a list of images, and I want to display only the comments associated with an images specified ImageID (for example 1473).

I need to display only the ones where the ID is equal to a specified value?

This must be easy, but for some reason, it is just flying over my head.

Thanks for you help!

  • 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-17T15:09:00+00:00Added an answer on May 17, 2026 at 3:09 pm

    Simplest way is to loop through ‘Comments’ associative array (aka dictionary) with foreach and check the value of ‘ID’ key, if it matches the desired value, print the value of ‘Comment’ key:

    $imageId = 1473;
    foreach($Comments as $comment) {
        if($comment['ID'] == $imageId) {
            echo $comment['Comment'];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MYSQL Database: I have a table of data that I need to put into
I have one Servlet that does insertion into my database. This is working fine.
I have a MySQL table holding lots of records that i want to give
I have a web form that manipulates records in a MySQL database. I have
I have a problem for querying records into mysql explanation below The user could
I have stored 6 records in mysql db,when i use this code each of
I have a mysql table that I need to only contain 20 newest records
I have a table with about 3000 records that I query often. Does mysql
I have a database that is MySQL / Php technology. I have a database
I have this mysql query using PHP and first part is working fine, but

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.