ShootingBlanks
11-14-2007, 05:23 PM
I made this function:
if (isset($_GET['orderType'])) {
switch($_GET['orderType']) {
case "ASC":
$orderType = "ASC";
break;
case "DESC":
$orderType = "DESC";
break;
default:
$orderType = "ASC";
}
} else {
$orderType = "ASC";
}
function switchOrder($orderType) {
if ($orderType == "ASC") {
$returnOrder = "DESC";
} else {
$returnOrder = "ASC";
}
return $returnOrder;
}
Then I have this link in the body of my document:
<a href="index.php?orderBy=leader&orderType="<?php echo switchOrder($orderType); ?>>Leader</a>
All that's supposed to happen is to have the "orderType" variable in the URL alternate between "ASC" and "DESC" everytime it's clicked. However, all that comes up when it's clicked is:
/index.php?orderBy=leader&orderType=
So, it's like it's not getting the $returnOrder variable from my function. What am I doing wrong here? I am pretty novice with PHP, so it may be a simple error. Thanks!...
if (isset($_GET['orderType'])) {
switch($_GET['orderType']) {
case "ASC":
$orderType = "ASC";
break;
case "DESC":
$orderType = "DESC";
break;
default:
$orderType = "ASC";
}
} else {
$orderType = "ASC";
}
function switchOrder($orderType) {
if ($orderType == "ASC") {
$returnOrder = "DESC";
} else {
$returnOrder = "ASC";
}
return $returnOrder;
}
Then I have this link in the body of my document:
<a href="index.php?orderBy=leader&orderType="<?php echo switchOrder($orderType); ?>>Leader</a>
All that's supposed to happen is to have the "orderType" variable in the URL alternate between "ASC" and "DESC" everytime it's clicked. However, all that comes up when it's clicked is:
/index.php?orderBy=leader&orderType=
So, it's like it's not getting the $returnOrder variable from my function. What am I doing wrong here? I am pretty novice with PHP, so it may be a simple error. Thanks!...