justlukeyou Posted May 25, 2012 Share Posted May 25, 2012 I am trying to filter a query very similiar to a blog. The idea is that when someone first goes to the site it shows all the articles with a category link next to the title so someone can click on a category. However, when they click on a category it shows all the articles but the category shows without a link so its just a piece of text. I have done this however I had to add an extra page which isn't ideal. Is it possible to make a category keyword appear with a link and then without a link. Link to comment https://forums.phpfreaks.com/topic/263109-querying-queries-with-slightly-different-designs/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 25, 2012 Share Posted May 25, 2012 Is it possible to make a category keyword appear with a link and then without a link. Of course, you would just use some if/else logic to get your code to do what you want when and where you want it to - <?php $selected_category = ...; // the actual selected category, gotten from however you are passing it between page requests // your code that is looping and displaying the categories on the page while($row = mysql_fetch_assoc($result)){ if($row['category'] == $selected_category){ // current category is the selected one, output as text echo $row['category']; } else { // current category is not the selected one, output as link echo "<a href='?cat={$row['category']}'>{$row['category']}</a>"; } } Link to comment https://forums.phpfreaks.com/topic/263109-querying-queries-with-slightly-different-designs/#findComment-1348590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.