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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:09:22+00:00 2026-06-17T22:09:22+00:00

I have a problem with looping through the pulled info form my database (MySQL)

  • 0

I have a problem with looping through the pulled info form my database (MySQL)

I want to pull all the ID from the Forum table, like this:

SELECT ID FROM Forums

then loop through all the ID’s and run

SELECT ID FROM Catagory WHERE Forum_ID = ?

This is the same in proper php:

$profile=$db->prepare('SELECT ID FROM Forums ');
$profile->execute();
$forums = $profile->fetch();

foreach ($forums as &$forum_ID) {

    // some code

    $profile=$db->prepare('SELECT ID FROM Catagories WHERE Forum_ID = ?');
    $profile->bindValue(1, $forum_ID);
    $profile->execute();
    $catagories = $profile->fetch();

    foreach ($categories as &$category_ID ) {

        //some more of my code
    }
}

With this code i get an error:

Undefined variable: categories

Please do not mind the spelling errors they are spelled that way in my database, im dyslectic

Thanks in advance

EDIT: For this test i made sure there is something to return by the SQL server

  • 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-17T22:09:23+00:00Added an answer on June 17, 2026 at 10:09 pm

    We don’t mind the spelling errors. But PHP minds,

    change $catagories into $categories.

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

Sidebar

Related Questions

I have a problem looping through my tableLegs for a bus timetable to find
I have a problem with looping through a set of XElements . The behavior
So i have a problem with taking an array and looping through the values
I'm trying to populate a dataset with records from a MySql database, then looping
Possible Duplicate: Looping through Markers with Google Maps API v3 Problem I have a
I have a bit of code where I am looping through all the select
I have the following PHP. Here I am creating a table, looping through the
So I have this problem while looping through a socket with a while loop.
Am try to looping through a database result set, the problem is that i
I have the following method for looping through a table, changint some values in

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.