I am trying to pull posts from a specific month that has been clicked on, on a different page….. So to make it a little more clear.
I have a page which displays each month that a post has been made in, I then have a second page that page one is linked to. The second page is for showing the posts from the month that has been selected in the previous page.
below is the code to display the months and the link I created for the user to click on
$months = mysql_query("SELECT DISTINCT(MONTHNAME(date)) as post_month
FROM article
LIMIT 12");
while($row = mysql_fetch_array($months)){
echo "<a href=\"montharticles.php?id=" . $row['0'] . "\">" . $row['0'] . "</a><br/>";
}
below is the code for the second page
$article = mysql_query("SELECT article_id, content, DATE_FORMAT(date, '%d %b %y')
FROM article
WHERE article_id = $_GET[id]");
while($row = mysql_fetch_array($article)){
echo $row . "</br>";
}
my issue is that when page two is opened I get an error message.
I have removed $_GET[id] and replaced it with a number, doing this just displays “array”
I have also tried $_GET[month] but no luck
I realise that there is a problem with the $_GET[] part of the statement and that if a month is clicked I need to make whats in the address bar = to whats in the $_GET command, but I cant work out how to do it.
In your code
$rowis an array that includes an entire row of the result set.To access a particular column in the row, you need to do something like this:
You’ll probably want to use an alias for the date column like this:
So you can do this:
Instead of this: