php - Multi variables by links -


i'm making news archive. want news archive have several options. @ first want archive have option display news posted in year , option display news thats posted in category. these features both saved in database @ every post small php code can find posts created in e.g 2013.

the problem is want make buttons in news archive. buttons can make user decide feature enabled or not (if understand i'm saying). want users have ability make sure posts of e.g 2013 appear on screen on same time posts of e.g sport news appear. making 2 features user enable, couldn't think of way linking them correct page.

if click on specific year go article.php?year=2013 example. if want use other feature (category) it's impossible because send article.php?category=sport example , posts no longer searched on published year on category.

i want make sure if 1 feature/option enabled other add &category=sport @ end of url url becomes article.php?year=2013&category=sport makes sure user can select multiple features @ same time.

   <ul class="archive">             <li>             <div>year</div>             <ul>             <li><a href="article.php?year=all">every year</a></li>             <li><a href="article.php?year=2013">2013</a></li>             <li><a href="article.php?year=2012">2012</a></li>             <li><a href="article.php?year=2011">2011</a></li>             <li><a href="article.php?year=2010">2010</a></li>      </ul>         </li>           </ul>     <ul class="archive">             <li>             <div>category</div>             <ul>             <li><a href="?category=all">general news</a></li>             <li><a href="article.php?category=sport">sport news</a></li>             <li><a href="article.php?category=international">international news</a></li>             <li><a href="article.php?category=national">national news</a></li>          </ul>         </li>           </ul> 

i hope understand problem , forward hear of you!

the basic solution (lazy too) dragging around possible parameters empy values when not needed, example have:

<ul class="archive">             <li>             <div>year</div>             <ul>             <li><a href="article.php?year=all&category=<?=$_get['category']?>">every year</a></li>             <li><a href="article.php?year=2013&category=<?=$_get['category']?>">2013</a></li>             <li><a href="article.php?year=2012&category=<?=$_get['category']?>">2012</a></li>             <li><a href="article.php?year=2011&category=<?=$_get['category']?>">2011</a></li>             <li><a href="article.php?year=2010&category=<?=$_get['category']?>">2010</a></li>      </ul>         </li>           </ul>     <ul class="archive">             <li>             <div>category</div>             <ul>             <li><a href="?category=all&year=<?=$_get['year']?>">general news</a></li>             <li><a href="article.php?category=sport&year=<?=$_get['year']?>">sport news</a></li>             <li><a href="article.php?category=international&year=<?=$_get['year']?>">international news</a></li>             <li><a href="article.php?category=national&year=<?=$_get['year']?>">national news</a></li>          </ul>         </li>           </ul> 

anyway reccomend build sort of automatic menĂ¹ generator, can add parameters , links without effort, example via "link generator" append needed parameters (i'll put in snippet if need).


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -