Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding to a parameter for category filtering
    text
    copied!<p>Ok so i have a question about PHP, and I don't know if i'm just being stupid or if this is just a lot harder than i thought :/</p> <p>So i'm trying to filter some results down through GET parameter's in the URL. I'm thinking the best way to do this would be similar to what ebuyer.com do.</p> <p>When you filter there search results by different category's the URl is built up like so</p> <pre><code>filtercat=36,134,142,62 etc </code></pre> <p>How are they adding to the parameter whilst keeping the rest of the selected category's?</p> <p>Help!</p> <p><strong>I'm basically trying to create what is on <a href="http://www.ebuyer.com/search?page=1&amp;sort=relevancy&amp;limit=10&amp;q=memory+card&amp;filtercat=48,36" rel="nofollow">this site</a>, on the left sidebar where you can select and deselect filters for your search</strong></p> <p>Many thanks for any replies</p> <p><strong>UPDATE</strong></p> <p>Below is some code but repeated clicking on the link causes multiple occurrences of the same value</p> <p>e.g. categories.php?filtercat=361343636</p> <p>how can I stop this and add commas in between so the output is?</p> <p>e.g. categories.php?filtercat=36,134 etc</p> <pre><code>&lt;?php $filter = $_GET['filtercat']; $pieces = explode(",", $filter); $edit_url = http_build_query( Array( 'filtercat' =&gt; ''.$pieces[0].$pieces[1].$pieces[2].'' ) ); echo($edit_url); ?&gt; </code></pre> <p>Then in my links I have </p> <pre><code>&lt;a href="&lt;?php echo('categories.php?'.$edit_url.'36'); ?&gt;"&gt;36catagory&lt;/a&gt; &lt;a href="&lt;?php echo('categories.php?'.$edit_url.'134'); ?&gt;"&gt;134catagory&lt;/a&gt; </code></pre> <p>The explode does not work though as there are no commas... the whole things a giant mess really and I'm so confused :/ Help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload