> -----Original Message-----
> From: Jason Wong [mailto:[EMAIL PROTECTED]
> Sent: 11 March 2004 14:19
>
> On Thursday 11 March 2004 21:15, I.A. Gray wrote:
>
> > 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.
>
> Try something like:
>
> if (isset($_GET['ORDER'])) {
> switch ($_GET['ORDER']) {
> case 'ASC' :
> case 'DESC' :
> case 'RAND' :
> $SPORDER = $_GET['ORDER'];
> break;
> default :
> $SPORDER = 'ASC';
> }}
> else {
> $SPORDER = 'ASC';
> }
Or even:
switch (@$_GET['ORDER']):
case 'ASC':
case 'DESC':
$SPORDER = $_GET['ORDER'];
break;
case 'RAND':
$SPORDER = 'RAND()';
break;
default :
$SPORDER = 'ASC';
endswitch;
(which, I think, also gives the requested result for 'RAND').
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6
3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php