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/>";
}