Every time I add a sort option to my directory, all of my links grow by an ifelse statement. So the link code is getting a little out of hand.
Right now I only have three sortable options but have serveral more that I would like to add.
Im looking for a better way to handle the following. Any Ideas?
$date= new : old
$views=most
$rating=top
$channel=can be anything
PHP Code:
echo '<ol>
<li>Sort By ></li>
<li><a href="sort.php?date='.($date == "new" ? "old" : "new").'&'; if(isset($_GET["channel"])){ echo 'channel='.$_GET["channel"].'&';} if(isset($views)){ echo 'views='.$views.'&';}if(iss et($rating)){ echo 'rating='.$rating.'';} echo ' ">'.($date == "new" ? "Oldest" : "Newest").'</a></li>
<li><a href="sort.php?';if(isset($date)){ echo 'date='.$date.'&';}if(isset($_GET["channel"])){ echo 'channel='.$_GET["channel"].'&';} echo 'views=most">Most Views</a></li>
<li><a href="sort.php?';if(isset($date)){ echo 'date='.$date.'&';}if(isset($_GET["channel"])){ echo 'channel='.$_GET["channel"].'&';} echo 'rating=top">Top Rated</a></li>
</ol>
';
edit: updated code.