How to make blog archive

i am making a blog and i need a blog archive.This is the code.

<dl class="accordion">
<?php
$showyear=mysql_query("SELECT `year` FROM `blogpost`");
while($farooq=mysql_fetch_array($showyear))
{
    $year=$farooq['year'];
    $_SESSION['blogarchive'][]=$year;
}
$blogarchive=$_SESSION['blogarchive'];
foreach($_SESSION['blogarchive'] as  $year)
{
    $showtitle=mysql_query("SELECT * FROM `blogpost` WHERE `year`='$year'");
    while($umar=mysql_fetch_array($showtitle))
{
    ?>
 <dt><a href=""><?php echo $year;?></a></dt>
<dd><a href="blogdetail.php?id=<?php echo $umar['post-id'];?>&action=profileblog"><?php echo $umar['title'];?></a></dd>   
    <?php
}
}

?>

</dl>

its out put is

    2011
2012
2013
2013
2013
    haider
2013
2013
2013
2013
2013
2013

i want to show all the 2013 post in one like that

2013(9) title title

so how can i do this ..

Answers


This will show you output as 2013(9)--

<?php

$showtitle=mysql_query("SELECT DISTINCT * FROM `blogpost` WHERE `year`='$year'");
while($umar=mysql_fetch_array($showtitle))
{
?>
<dt><a href=""><?php echo $year;?></a></dt>
<dd><a href="blogdetail.php?id=<?php echo $umar[`year`];?>&action=profileblog"><?php echo $umar['title']."(".mysql_query("SELECT COUNT(*) FROM `blogspot` WHERE `post-id`=".$umar['post-id'].")";?></a></dd>   
<?php
}

?>

Need Your Help

Parsing a Quickbook IIF format file

c# parsing io text-parsing fileparsing

I'm working with Quickbook's IIF file format and I need to write a parser to read and write IIF files and I'm running into some issues reading the files.

Telerik treeview bind to model

jquery asp.net-mvc-3 razor telerik

How to set Telerik tree view bind to model? Is it possible to bind the root node and child node from same table? I am trying like follows: