views:

54

answers:

3

I have a client who is wanting to create a link which contains product codes so that his customers hit a page with just those products displayed in an attempt to increase conversion rates from affilliate sites.

My question is whats the best way to send these multiple products in a single URL

For example:

http://www.mydomain.co.uk/bespoke-list.php?catNo=234-324-232-343

Obviously then the site would grab the codes from the string and display them...

We're going to be using PHP!

Thanks in advance.

+2  A: 

You can certainly send the like you described, with - as separator. The querystring variables are stored in the $_GET array in PHP, so your example numbers can be accessed like this:

$ids = $_GET['catNo'];
$ids = explode('-', $ids);
foreach($ids as $id) {
  echo "<p>$id</p>"; //Do something with $id here.
}

Another way could be to store them directly as an array in the querystring, like this:

http://www.mydomain.co.uk/bespoke-list.php?id[]=234&amp;id[]=324&amp;id[]=232&amp;id[]=343

Then you can get the ids directly without explode:

$ids = $_GET['id'];
foreach($ids as $id) {
  echo "<p>$id</p>"; //Do something with $id here.
}

But when I look at it, the first one is certainly a more attractive URL. :-)

Emil Vikström
Thats what i was thinking :) About attractive URL. And also easier to give over to clients so they understand it. Thanks for your input.
Andy
A: 

If you want to make URL look better, you could do it by using .htaccess file.

Eugene
definitely, for this task though we're not bothered about SEO and its quicker to write product codes, but valid point!
Andy
A: 

I would construct the query string with a prefix for each product "catNo-" as follows:

catNo-1=234&catNo-2=324&catNo-3=232&catNo-4=343

The php code to parse the above query string:

<?php
$catNoPrefix = "catNo-";
foreach($_GET as $key => $value){
    if("FALSE" != strstr($key, $catNoPrefix )) {
        $idValue = $_GET[$key];
        echo "<p>$idValue</p>"; 
    }
}
?>
URLParser.com