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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:09:42+00:00 2026-06-12T00:09:42+00:00

Forewarning: I am bad at CSS. Hello, I am working on a little message

  • 0

Forewarning: I am bad at CSS.

Hello,
I am working on a little message board which displays the 3 most recent posts.
I would also like the user to choose how many posts are displayed on one screen,
say 5 or 10 posts.

Currently I have it so that all posts are printed out in this manner:

while ($i < $d){
// $d is entered by the user to determine how many posts are to be displayed.
    if ($i == $id_Max){
        echo "Reached last known post.";
        break;
    }

    $query2 = $con->prepare(
    "SELECT postName, postPath FROM " . $table .
    " WHERE id=(SELECT MAX(id-".$i.") FROM " . $table . ")"
    );
    $query2->execute();
    $result2 = $query2->fetch();
    $path = $result2["postPath"];
    $file = file_get_contents($path);

    echo "<article class = 'entry'>";

    echo "<section id = 'entryTitle'>";
    echo $result2["postName"] . "<br />";
    echo "</section>";

    echo $file;
    echo "<br />";

    echo "</article>";

    $i++;
}

So, each post that is printed has the class of entry. With this I gave each post a border, but I want to make it so that there is a space of about 5px between them.
I set their position: relative and top: 5px but it only takes effect on the top most entry and moves them all down by 5px from the very top of the page.

Essentially, I want to have something work globally with out having to write out something for each possible post. #entry1, #entry2…

I am look not really for how to do this specific thing, but more of something that I can learn from to apply in future things.

Thanks,
– Michael Mitchell

(If I was not clear, please tell me and I will attempt to explain better.)

  • 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-12T00:09:43+00:00Added an answer on June 12, 2026 at 12:09 am

    There’s a few things I see going on wrong here.

    First of all, spacing between elements is typically handled with margins:

    /* all .entry elements */
    .entry { margin-top: 10px }
    /* all but the first .entry elements */
    .entry + .entry { margin-top: 10px }
    

    Second, it looks like you are making multiple requests to the database when you don’t really need to. The query you want looks like this:

    SELECT postName, postPath FROM tablename ORDER BY date_added DESC LIMIT ?
    

    This will give you a list of the top entries that you can iterate through and is much faster than making multiple requests. If you want the number of entries return to be configurable, make absolutely sure you are sanitizing/escaping the value.

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

Sidebar

Related Questions

I am very unfamiliar with nginx, as a forewarning, and also can't find any
Hello i have error when i am forwarding page without parameter. that is happen
i have an arraylist of strings in my servlet which im passing forwarding using
A user of my app out in the field seems to having bad crash-at-app-start
I have some python module, which has a class ModuleClass and I can't modify
Forewarning: a potentially silly question, purely out of curiosity. If, for example, I perform
Which X11 forwarding under Windows solution do you recommmend ? I'd like to get
I am trying to create a simple C# app which does port forwarding, and
I have two css columns for my website they fit inside a main container,
I am working on simple iphone application. where i am working on two views.

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.