How to pass the value and show article title list?

i want to echo something like the following in a file(eg: test.php).


the code output it may be:

$months = 10; //count of months 
$date = date_create( 'now' );
echo date_format( $date, 'Y M' );
for ( $i = 0; $i < $months; $i++ ) {
    date_sub( $date , date_interval_create_from_date_string( '1 months' ) );
    echo date_format( $date, 'Y M' );

i fell the code isn’t very good. the above is the year-month archive. now i want to when the user click the year-month. then in the current page shows each articles’ title with list that belong to the year-month. i know i should use a passed value into my database query then select out each articles’ title.supposed each article created time is stored as this 15806927473. but i don’t know how to passed the value. when the user click the year-month. and use the passed value in my sql query. thank you.

Pass the year and the month in the query string of the link (f.e. page.php?yearmonth=201105).
Use that value in the called php script ($_GET[‘yearmonth’]).

each article created time is stored as this 15806927473

You’ll have to transform the yearmonth value into this date format before using it in the query.

i am sorry, i am new of php,. could you give me a simple example?

Guido2004 is right, a simple example would be this

test.php echo out some sort of html, the year and month are presumable links,
just echo out the dates as well into ur a href e.g.

<a href="sompage.php?date=201105">201105</a>

then the somepage.php could have something like this

$date = $_GET['date']; // eg. 201105

and that should do it!