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 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 easy but I am getting stuck: when I build a solution
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
This is probably an easy question, but I want to understand better how Apache
This is probably one of those easy questions.. I'm trying to redirect the user
This is probably easy, but I couldn't find an answer anywhere. I'm filling a
There is probably an easy solution to this, but I can't figure it out.
This problem is probably very easy to solve but somehow I cannot find a
this is probably really easy, but here goes: My changes to the magento email
This is probably v.easy but my php is very rusty. I need to implement

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.