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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:17:45+00:00 2026-05-20T09:17:45+00:00

This is probably an easy fix – but I’ve been getting A LOT of

  • 0

This is probably an easy fix – but I’ve been getting A LOT of issues trying to set this up. Basically I’m trying to create a category menu for an article page. The “list” has each category and underneath that list would be each article with the same attribute.

I have two tables set up one that holds all the categories and the other which holds the news posts. Yet for some reason…only the first post shows up – not the latter…

For example:

African Animals

Lion

Elephant

Farm Animals

Pig

<?php
    $STH = $DBH->query('SELECT * FROM articles_category');
        while($row = $STH->fetch()) { 
            echo "<li>\n";
            echo "<a href='' class='nav-top-item'>". $row['category'] ."</a>\n";
            echo "<ul>\n";
            $STH = $DBH->query('SELECT * FROM articles WHERE category="'. $row['category'] .'"');
                    while($row = $STH->fetch()) { 
                        echo "<li><a href='articles/article?id=". $row['id'] ."'>". $row['title'] ."</a></li>\n";
                    }
            echo "</ul>\n";
            echo "</li>\n";
            }   
?> 
  • 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-20T09:17:46+00:00Added an answer on May 20, 2026 at 9:17 am
    $STH_2 = $DBH->query('SELECT * FROM articles ...'
    while($row_2 = $STH_2->fetch()) {
       echo "<li><a href='articles/article?id=". $row_2['id'] ."'>". $row_2['title'] ."</a></li>\n";
    } 
    

    You are loading subcategory to same array $STH, change name, and second while should have different name too -> $row_2 will help

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

Sidebar

Related Questions

This is probably blatantly simple and easy to fix (or impossible) but I've been
This is probably easy, but I'm trying to convert from a source which provides
This is probably an easy fix, but I'm stumped. Here's the URL: http://urgent.mchenry.edu First
This probably very easy when you know how, but I don't :) I'm trying
I know the fix to this is probably rather easy, but how would I
This is probably easy but I am getting stuck: when I build a solution
I've been working all day and I somehow can't get this probably easy task
This is probably really easy but I can't seem to figure out how to
This is probably seriously easy to solve for most of you but I cannot
This is probably really easy, but I'm lost on how to make sure it

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.