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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:02:29+00:00 2026-05-28T00:02:29+00:00

I’m still pretty new to php and mysql, I’ve build a basic CMS for

  • 0

I’m still pretty new to php and mysql, I’ve build a basic CMS for my news articles and events etc on my site and I need a button that will add a new year category.

I currently have a form button for 2011 articles so when a user clicks it my news page will get the value 2011 which is hidden and only show articles with the year 2011.

I was thinking of maybe using an array so that when I click add new category it just adds 1 to the year 2011 and I can grab the array values and use them some how to add to where I store my hidden form value when I generate a second form / third …. etc.

I hope that makes sense, if anyone knows an easier way to do this I’m open to ideas. heres the code I use currently


news.php

<form action="all-news.php" method="POST" name="editform">
    <input type="hidden" name="category" value="2013"/>
    <input type="hidden" name="item" value="1"/>
    <input type="submit" style="padding: 2px 15px;background-color:#C00; color:#FFF; margin:10px; font-size:18px; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif" name="go" value="News Articles 2013">
    </form>

newslist.php

    $category = $_POST['category'];

        $query = "SELECT * FROM sitecontent WHERE $category = Post_Year ORDER BY Date DESC";
        $result = mysql_query($query);

        while($posts = mysql_fetch_array($result)){
            echo "<div>";
            echo "<h3>", $posts['Post_Title'], "</h3>", "<br/>";
            echo "<a href=\"delete.php?id=$posts[ID]\"> ", "<span style=\"cursor:pointer; padding: 2px 8px;background-color:#C00; color:#FFF; margin-right:10px;\">" , "Delete", "</span>" , "</a>";
            echo "<a href=\"edit.php?id=$posts[ID]\"> ", "<span style=\"cursor:pointer; padding: 2px 8px;background-color:#C00; color:#FFF; margin-right:10px;\">" , "Edit", "</span>" , "</a>";
            echo "</div><br/>";

        }
  • 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-28T00:02:30+00:00Added an answer on May 28, 2026 at 12:02 am

    I recommend you put your styles in another file to keep things clean. Try this:


    style.css

    .button {
        padding: 2px 15px;
        background-color: #C00; 
        color: #FFF; 
        margin: 10px; 
        font-size: 18px; 
        font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
    }
    

    news.php

    <link rel="stylesheet" type="text/css" href="path/to/style.css">
    <?php
    $query = mysql_query("SELECT * FROM sitecontent ORDER BY Date DESC");
    while($posts = mysql_fetch_array($query)) {
        if(!in_array($posts["Post_Year"], $desiredYears))
        {
            $desiredYears[count($desiredYears)] = $posts["Post_Year"];
        }
    }
    
    foreach($desiredYears as $currentYear)
    {
        ?>
        <form action="all-news.php" method="POST" name="editform">
            <input type="hidden" name="category" value="<?php echo $currentYear; ?>"/>
            <input type="hidden" name="item" value="1"/>
            <input type="submit" name="go" class="button" value="News Articles <?php echo $currentYear; ?>">
        </form>
        <?php
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.