Forum Moderators: coopster

Message Too Old, No Replies

I need help with a Sort script

sort script

         

gearupandplay

12:49 am on Jun 28, 2008 (gmt 0)

10+ Year Member



Hi, I dont know if this is possible but I would like to take the script below and add something to it that sorts the results that it pulls. The script is what you get from popshops and pulls the selected products. I would like to sort them by price. Any Ideas?

<?php
# Determine the current base URL
if(!isset($_SERVER['REQUEST_URI'])) {
$psps_base_url = $_SERVER['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $psps_base_url .= $HTTP_SERVER_VARS['QUERY_STRING']; }
} else {
$psps_base_url = $_SERVER['REQUEST_URI'];
}

$psps_parameters = '';

foreach ($_REQUEST as $key => $value) {
if (strpos($key,"psps_") > -1 ) {
$psps_parameters .= '&'.$key.'='.urlencode($value);
$psps_base_url = str_replace('&'.$key.'='.urlencode($value), "", $psps_base_url);
$psps_base_url = str_replace($key.'='.urlencode($value), "", $psps_base_url);
}
}

$psps_parameters .= "&psps_show_search=true";
$psps_parameters .= "&psps_show_navigation=true";
$psps_parameters .= "&psps_show_products=true";

$psps_url = "?psps_base_url=".urlencode($psps_base_url);

$psps_url="http://example.com/shops/php/654zcsroiuyfiiwvnfqc06xax$psps_url$psps_parameters";

# Include the shop
if (function_exists('curl_init')) {
$shop=curl_init();
curl_setopt($shop,CURLOPT_URL,$psps_url);
curl_exec($shop);
curl_close($shop);
} else {
readfile($psps_url);
}
?>

[edited by: eelixduppy at 2:28 am (utc) on June 28, 2008]
[edit reason] example.com [/edit]

siMKin

9:44 am on Jun 28, 2008 (gmt 0)

10+ Year Member



i see a lot of code, but nothing with a price ..... so i'm not sure where exactly you are stuck
Anyways, have a look at the uasort() function in the manual ... from what i understand i think that is the key to solving your problem

gearupandplay

11:56 am on Jun 28, 2008 (gmt 0)

10+ Year Member



Hi simkin, thanks for your reply. I see what you mean, I don't see a price either so I wonder if its even possible at this step.
I'm not sure if you are familiar with popshops but after you select products this is the code they give you to put in your store for the items to appear. Unfortunately at this time they do not have any feature that allows you to sort the products, by lets say price, name, etc when you import them. I'm wondering if this would have to be done somewhere else, maybe on their end and I'm just stuck until they come up with the feature.

siMKin

2:49 pm on Jun 29, 2008 (gmt 0)

10+ Year Member



No, i'm not familiar with them.

I think you should be able to solve the problem on your side, but first you'll need to know how you can access the array with the information. What the name of that array is and how it is constructed. Once you know the name a simple var_dump() will tell you more about how it is composed.