Hi everyone,

I know this is probably really simple, but I am not very good at expressions
and conditional statements.  I am wanting to show a list from a MYSQL
database.  I am using the URL to store the variables that control the
output.  The variable $ORDER can be set to ASC (Ascending), DESC (Descending
and RAND (Random).  What I want the script to do is set $SPORDER to this
value.  If $_GET['ORDER'] is not set then it gets the default value (ASC),
if this is any other than ASC, DESC or RAND (ie. someone has messed with the
variables in the URL) then it also gets the default (ASC). Finally if
$_GET['ORDER'] is set to RAND then I want $SPORDER to equal RAND() so that I
can use the value in the SQL query.

Here is part of the script:

<?php

                                if (!isset($_GET['ORDER'])) { // Checks if the 'ORDER' 
variable from the
URL is set.  If it is NOT set the following happens...
                                $SPORDER = "ASC"; // The variable $SPORDER is given 
the value ASC, since
ASC (Ascending Order) is the default value.
                                }
                                else { // The following happens if the 'ORDER' 
variable IS set...
                                        $SPORDER = $_GET['ORDER']; // The variable 
$SPORDER is given the value
of the variable 'ORDER' taken from the URL.
                                        if  ( (($SPORDER !== "ASC") && ($SPORDER !== 
"DESC")) && ($SPORDER !==
"RAND")) { // If the variable $SPORDER does NOT have the value of either
"ASC" (Ascending), "DESC" (Descending) or "RAND" (Random) then the following
happens...
                                                $SPORDER == "ASC";  // The variable 
$SPORDER is given the default
value "ASC"
                                                }
                                        else { // If the variable $SPORDER DOES have 
the value of either "ASC",
"DESC" or "RAND" then the following happens...
                                                if ($SPORDER == "RAND") { // If 
$SPORDER has the following of "RAND"
(Random Order) then...
                                                        $SPORDER == "RAND()"; // 
$SPORDER is given the value "RAND()" which
is the correct value for submission to the MYSQL query.
                                                        }
                                                }

                                        } // End of the Conditional Statements 
regarding the ORDER variable.

?>

I think the problem part could be: if  ( (($SPORDER !== "ASC") && ($SPORDER
!== "DESC")) && ($SPORDER !== "RAND"))

I am trying to say if $SPORDER does not equal "ASC", "DESC" or "RAND" then
do the following.  There maybe other problems in my code as well that are
not making this work.  I would be grateful if you could shed some light on
it!

Best wishes,
Ian Gray

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to