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

Wildcard string matching in Ruby

ruby pattern-matching glob string-matching

I'd like to write a utility function/module that'll provide simple wildcard/glob matching to strings. The reason I'm not using regular expressions is that the user will be the one who'll end up pro...

Change rule selectorText from JS?

javascript css dom

Is it possible to change a CSSRule's .selectorText from javascript ? MDN says it is a getter/setter but setting it seems to have no effect...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.